How can I do the following in a conditional?
$(function () {
$("[id*='_btnCheck']").click(function () {
var buttonName = $(this).attr('id');
ChannelEvent(buttonName);
});
$("[id*='_btnRuta']").click(function () {
var buttonRuta = $(this).attr('id');
RouteEvent(buttonRuta);
});
});
If I click on any button that carries in the id _btnCheck
then something happens, if I click on a button that takes in the id _btnRuta
then something happens, and finally if I click on a button that carries id _btnCliente
then something happens.
My code is functional, but I have been left with this small limitation.
Update:
I'll explain myself better let's say I have 10 buttons and these are from the group A
, another 10 buttons are from group B
, other 10 group C
.
Each button has a different ID. The code that I have put is to track a key within the id button. If we are in the group A
. all buttons carry the key: _btnCheck
, but obvious the full ID of a button in group A can be: e1_btnCheck
, Other is e2_btnCheck
, Other is e3_btnCheck
and so on.
So when I click on them, they take me to the same method thanks to the key that contains a part of the ID.
Well, now, there are many buttons but these are grouped thanks to that key.
When I use:
$(function () {
$("[id*='_btnCheck']").click(function () {
var buttonName = $(this).attr('id');
ChannelEvent(buttonName);
});
});
The button responds with I wish and guides me to the event, which then becomes a webmethod on ASP.net.
If I put the code to find the following groups, B
and C
. The click event does not fire. Only for group A
only. So I was thinking about doing a conditional which may work.
If you have a better idea, welcome it. I'm not very good at JS. Thanks.