Issue
<select>
<div class="options">
<option value="nothing">Nothing</option>
<option value="snothing">Second Nothing</option>
</div>
</select>
I want to get the content of the DIV and print it inside javascript in a selector.
$(document).ready(function () {
var options = $('.options').html();
.
.
.
var content = '<select>' + options + '</select>';
.
.
.
});
I need to take options from the HTML. I've created a div indise <select></select>
tags, because I had no other idea. But it's not working!
I tried to put the options var inside <p></p>
tags so i can print it, it sais 'undefined'.
Solution
Assuming the missing >
is a typo, your structure is invalid. select
elements cannot have div
elements as direct children.
You could do this:
<select class="options">
<option value="nothing">Nothing</option>
<option value="snothing">Second Nothing</option>
</select>
And then
var options = $('.options').html();
Answered By - T.J. Crowder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.