I am developing a discussion panel in asp.net in which I am using the jquery selector option with two classes
$("#plblDisAgreeProblem", "plblDisAgreeComment").click(function(){
var str = {
problemID: $("#problemID").val(),
empID : $("#empID").val(),
commentID : -1
}
$.ajax({
type: "GET",
url: "<%= Url.Action("GetStatus", "Discussion") %>",
data: str,
error: function(msg){
alert("error2" + msg);
},
success: function (msg) {
var out = msg.split("<br/>");
if (out[1] == "DisAgree: True")
{
alert("You are already disagree to this problem.");
}
else
{
}
});
})
I want if the class of div is ‘plblDisAgreeProblem’ then in JSon commentID should be -1 and if the class of div is ‘plblDisAgreeComment’ then in JSon commentID should be this.id but how I can do this?
Please Help me
First lets fix the missing dot in your class selector.. see below,
Then you can use hasClass function to check if the clicked element is from the specified class.. see below,
We don’t need an
else if of ('plblDisAgreeProblem')because it is defaulted to -1.