JQuery html () instead of val ()

I have a select list highlighted by the jquery wrapper. the problem is when I select the select element, the value of the select box is before the id val () message and I want it to be html () in between. but if i put html () instead of val () i get all html of optt opttroup.

the jquery part where I'm having problems:



(here I am setting val) and html:

<select name="123_cat" class ="styled">  
   <?php foreach($subcategories['categories'] as $sc) { ?>
   <optgroup label="<?php echo $sc['name']; ?>">
    <?php foreach ($sc['subcategories'] as $ss){?>                              
             <option id = "123_cat[]" value="<?php echo $ss['sid']; ?>" <?php if (isset($_POST['123_cat'])) { if($ss['sid'] == $_POST['123_cat']) echo 'selected = "selected"';} else { if(in_array($ss['sid'], $the_subcategories)) echo 'selected = "selected"'; } ?>><?php echo $ss['name']; ?></option>
        <?php }?>



How can I get the text between the <option>


selected onclick instead of its value?


source to share

1 answer

Have you tried using

$("option:selected", this).text()




All Articles