jquery - Table Header manipulation -
I'm using it as a combination with the Tanner plug-in, my goal is to add an empty class attribute That is to be sorted, that is, when I click on a column, class properties are removed in others.
I have a completely header table, basically what I want to be able to do I click on a table header, I want all the other tables to remove my CSS class But, what I am clicking on should be toggle between two CSS classes. I am using a Reliance Tag inside an anchor tag in the contents of the header, I do this because we are using XHTML strict and Reliance can not be defined in the table header tag. My code is as follows:
$ (function () {$ ("a [rel = 'header']). Click (function () {$ (" a [rel = header ' ] () () ($ (This) ($ (this) .attr ("class") == "sort-up") {$ (this) .removeClass ("sort-up");} if ($ {$ (This) .attr ("class") == "sort-down") $ $ (this) .removeClass ("sort-down");}} if ($ (this) .attr ("class") = = "") {$ (This) .addClass ("sort-up");} $ (this) .toggleClass ("sort-down")}}} I I am assuming that as soon as the header is clicked, there is a cycle through each header, if the class attribute in it is "sort- If it is, then delete it; if it has a class attribute "sort-down", then delete it. Then, for the currently clicked header, add the class attribute "sort-up" and the "sort-down" attribute Toggle between. My problem is that when I click on a header, if it is using the "sort-down" class, which is displayed in the header by the down arrow (/), then I go Clicks the second header in a different column I will remove the "sort-up" class (^), though not to remove the attribute.
Here is a list of my headers in XHTML:
& lt; Thead & gt; & Lt; TR & gt; & Lt; Th & gt; & Lt; A rel = "header" href = "#" class = "" & gt; Title & lt; / A & gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; A rel = "header" href = "#" class = "" & gt; Instructor & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "{sorter: 'ur longitude'}" & gt; & Lt; A rel = "header" href = "#" class = "" & gt; Date & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "{sorter: wrong}" & gt; Start / End & lt; / Th & gt; & Lt; Th & gt; & Lt; A rel = "header" href = "#" class = "" & gt; Available seats & lt; / A & gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; A rel = "header" href = "#" class = "" & gt; Nominated & lt; / A & gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; A rel = "header" href = "#" class = "" & gt; Pre-Needs & lt; / A & gt; & Lt; / Th & gt; & Lt; Th class = "{sorter: wrong}" & gt; Workshop Actions & lt; / Th & gt; & Lt; / TR & gt; & Lt; / Thead & gt; Waxwing, the stupid mistake was updated with the changes recommended, this works, I was not paying attention to the syntax of hasClass. (Function () {$ ("a [rel = 'header']). Click (function () {$ (" a [rel = 'header'] "). Each (function () {if ($ (this) .hasClass ("sort-up") {$ (this) .removeClass ("sort-up");} if ($ (this) .hasClass ("($ (This) .hasClass ("")) {$ (this) .addClass ("sort-down"). $ (This) .removeClass ("sort-down");}} ("sort-up") AddClass ("Sort-down");} and {$ (.) .removeClass ("sort-down"). AddClass ("sort-up");} ($ (this) .attr ("title") == " Sort order column in ascending order ") {$ (this) .attr ({title:" sorted column in descending order "}) other {$ (this) .attr ({title:" column sorted in ascending order "} );}});});
$ (function () {e}
Comments
Post a Comment