Change from javascript to jquery to line 2

-1

How can I select element number 2 using jquery? I'm selecting with javascript but would like to use Jquery.

34m
1- var hiddenFieldName = ‘UIHiddenFieldSubjectValidaty’ + jQuery("#UIDropDownListValidity option:selected").val(); vai buscar valor do id da select

2-var newSubjectText = document.getElementById(hiddenFieldName).value;
vai buscar os valores da select…

3-jQuery("#UITextBoxSubject").val(newSubjectText);
coloca os valor da select na textbox

    
asked by anonymous 14.06.2018 / 17:32

1 answer

0

You do not need to select the element this way, instead of selecting it in this way, use the id = # selector and pass the element name, like this:

var newSubjectText = $('#hiddenFieldName').val();

An example would be with the selector of classe = .

var newSubjectText = $('.hiddenFieldName').val();

In your example, you are trying to capture the value of an element that does not exist, it is already saved in the hiddenFieldName variable, you do not need to capture the value again.

    
14.06.2018 / 17:46