jquery append not working in IE works fine in FF

this code works fine in FF, not in IE.

var target = $("#targetSelectBox")
var vals   = values.split(";");
for (var i = 0; i < vals.length; i++) {
        var parts = vals[i].split(":");
 target.append($('<option />').val(parts[0].trim()).text(parts[1].trim()));
}

Answers


You're missing a semi-colon after the first line:

var target = $("#targetSelectBox")//;

Be sure that this selector is actually finding your element:

<select id="targetSelectBox">
  <!-- options to come -->
</select>

We'll also need to see the full portion of your code, including what values is to begin with. Additionally, make sure that jQuery is properly referenced, and you might even consider wrapper your inner target reference in the jQuery wrapper as well:

var newOption = $("<option>").val( parts[0] ).text( parts[1] );
$(target).append(newOption);

Functional example online: http://jsbin.com/ibeci/edit


Need Your Help

Symfony2 POST value from Twig to controller action

php symfony2

I'm new in Symfony2.I want to post a value from twig to controller. I know how to pass values through url. But i want How to post a data from twig to a controller action without passing that values...

Updating Javascript

javascript html time auto-update getelementbyid

I'm trying to create an updating clock in Javascript. Everything is working correctly as I step through the debugger, except that it's not actually updating the span. Any ideas why?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.