'JavaScript runs in Firefox, but not IE or Chrome?

I have the following JavaScript in my site :

 $(function() {
    var $cells = $("td");

    $("#search").keyup(function() {
        var val = $.trim(this.value).toUpperCase();
        if (val === "")
            $cells.parent().show();
        else {
            $cells.parent().hide();
            $cells.filter(function() {
                return -1 != $(this).text().toUpperCase().indexOf(val);
            }).parent().show();
        }
    });
});​

Link to it in action.

This example works in all browsers, so I assume the problem is with my HTML somewhere. Here is the relevant part:

  <div id="searchContainer">
                <input id="search" type="text">
            </div>
                <table>
                <tr>
                    <th>Username</th>
                    <th>Full name</th> 
                    <th>Tick to select</th>
               </tr>
           @foreach (var user in result) {
            <tr><td>@user.Username</td> <td>@user.FirstName @user.SecondName</td>
                <td><input type="checkbox" name="userId" value="@user.UserId" /></td></tr>
                }

The error I am thinking must be here since the code works perfectly in Firefox but does not run at all in Chrome or IE.



Solution 1:[1]

Maybe because you are missing the closing / on your input search box...

<input id="search" type="text">

should be

<input id="search" type="text" />

If not, try posting the generated source, to ensure what the client is actually seing rather than what asp.net is seeing (I'm assuming you are using Asp.net mvc with razor?).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rusmus