Mare22
asked on
JQuery accessing attributes from click event
I am working with JQuery 1.4 and Visual Studio 2010.
I have a radio button:
<div>
<asp:RadioButton runat="server" ID="C" Text=" ..." code="cd" />
</div>
and a click event handler:
$(document).ready(function () {
var rb = '#<%=myID.ClientID%>';
$(rb).click(function () {
var code = $(this).attr("code");
});
});
I need to get the button's attributes, but they come in undefined. How can this be fixed?
Thank you.
I have a radio button:
<div>
<asp:RadioButton runat="server" ID="C" Text=" ..." code="cd" />
</div>
and a click event handler:
$(document).ready(function
var rb = '#<%=myID.ClientID%>';
$(rb).click(function () {
var code = $(this).attr("code");
});
});
I need to get the button's attributes, but they come in undefined. How can this be fixed?
Thank you.
you should be able to use : $(this).next("label").text ()
Check this page, the html is the one generated by .net : http://jsfiddle.net/EAvsh/5/
Check this page, the html is the one generated by .net : http://jsfiddle.net/EAvsh/5/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've actually used $(this).parent, but your comment helped.
Thank you.
Thank you.
ASKER
$(":radio", ".petsRadioButton").each(f
$("form").append("<input type='radio' name='" + $(this).attr("name") + "' style='display:none' value='0' />");
})
$(":radio:visible", ".petsRadioButton").click(
var breedCode = $(this).attr("breedCode");
var txt = $(this).attr("Text");
debugger
var $bro = $(":radio[name='" + $(this).attr("name") + "']").not(this);
if ($bro.val() == "0") {
$bro.val("1");
$bro.attr("checked", false);
}
else {
$bro.val("0");
$bro.trigger("click");
}
var checked = $(this).attr("checked");
if (checked == undefined) {
checked = false;
}
else {
checked = true;
}
});
breedCode and txt are undefined.