I have the following HTML:
<tr>
<td class="ui-widget-content">
<a title="Edit" href="/Administration/Menus/Edit/001W"
class="editLink ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only"
role="button">
<span class="ui-button-text">Edit</span>
</a>
</td>
<td class="ui-widget-content">001W</td>
</tr>
To the editLink class I apply the following:
$('.editLink')
.button({ icons: { primary: "ui-icon-clipboard"} })
.removeClass('ui-button-text-icon-primary')
.addClass('ui-button-icon-only')
.click(function () {
editClick(this);
return false;
});
Is there a way that I can make it so I call the editClick function with the value of the following <td> as a second argument?
So for example in this case it would be the same as calling editClick(this,”001W”)
Yep.
You can use
$(this).closest('td').next().text()to do that.See
closest(),next()andtext()in the jQuery documentation.You could also use
$(this).parent().next().text()if you can guarantee the DOM structure of thetd‘s, but I’d prefer the use ofclosest()to make it more versatile.