Question

I am using MVC with C#.

I need to get the value from the hidden field of the active accordion in $(document).ready function.

Was it helpful?

Solution

accordion doesn't add the class selected, but ui-accordion-content-active.

Try:

alert('value ' + $('.ui-accordion .ui-accordion-content-active input[name$=EId]').val());

OTHER TIPS

Without knowing in more detail what your actual code is like, this is the closest guess I can give:

$(".ui-accordion .selected input[type=hidden]").val();

jQuery UI accordions have a "ui-accordion" class and automatically apply the "selected" class to the currently expanded accordion element.

I have run into this "strangeness" with jQuery; it seems the selector is returning an array of objects so you have to use the "[0]" to get the element you are looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top