Change from javascript to jquery to codeline 2

Asked

Viewed 35 times

-1

How can I select element number 2 using jquery? I am 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

inserir a descrição da imagem aqui

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

  • I did so , also gave error in the same.

  • Also I did, so, always error, as I will search id in select, then I take the value of id. with javascript works, but jquery always gives error, already expressed this, way.....

  • Dude, the value is already saved in the variable, just do it like this: var newSubjectText = hiddenFieldName;

  • var hiddenFieldName contains this value = Uihiddenfieldsubjectvalidaty360. when I do getElement contains this value = NOS Follow Car + share position during the next 15 minutes.

1 answer

0


You don’t need to select the element this way, instead of selecting it that way, use the selector id = # and pass the element name, like this:

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

An example if it were with the selector of classe = .

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.