Tuesday 15 March 2011

jquery - Class not being added to element -



jquery - Class not being added to element -

i can't figure out why class isn't beingness added selected td element.

example of date cell in jquery datepicker table...

<td class=" " data-handler="selectday" data-event="click" data-month="9" data-year="2014"> <a class="ui-state-default" href="#">1</a> </td>

what i'm trying jquery...

<script> var datelist = [ 1, 10, 2014 ]; $("td[data-month='" + datelist[1] + "'][data-year='" + datelist[2] + "']") .filter(function() { homecoming $(this).text() === datelist[0]; }).addclass("cal-selected-date"); </script>

any advice? thanks.

you need homecoming result in filter:

return $(this).trim() === datelist[0];

edit:

since not selecting a td instead, need add together .trim() trim off whitespace. , lastly not to the lowest degree either need convert both number or remove single =

return $(this).text().trim() == datelist[0];

or

return number($(this).text().trim()) === datelist[0];

jquery

No comments:

Post a Comment