I have no idea what what to do. Actually i need id of the control(element/tag),
when key up on any control . if more attributes(name,style,etc) exist get all attribute values also.
thank you.
I have no idea what what to do. Actually i need id of the control(element/tag),
when key up on any control . if more attributes(name,style,etc) exist get all attribute values also.
thank you.
According to jquery: get id from class selector
$('.clsName').click(function() {
alert( this.id );
});
I have tested it properly.
You can use:
$(this).attr('id');
using javascript
this.id;
Full code:
$(".clsName").keyup(function () {
$(this).attr('id');
});
Update:
You are having the dom:
<div class="clsName">
<input type="number" name="first" id="first">
<input type="number" name="second" id="second">
<input type="number" name="third" id="third">
That means you have used wrong selector to target input. it should be:
$(".clsName input").keyup(function () {
console.log($(this).attr('id'));
});
Use this.id
in pure javascript and use input event handler
$(".clsName input").on("input",function () {
console.log(this.id);
});
It's not quite an alias for keyup because keyup will fire even if the key does nothing (for example: pressing and then releasing the Control key will trigger a keyup event).
A good way to think about it is like this: it's an event that triggers whenever the input changes. This includes -- but is not limited to -- pressing keys which modify the input (so, for example, Ctrl by itself will not trigger the event, but Ctrl-V to paste some text will), selecting an auto-completion option, Linux-style middle-click paste, drag-and-drop, and lots of other things.
Use .attr()
in jquery.
$(".clsName").keyup(function () {
$(this).attr('id');
});
$(".clsName").keyup(function () {
var id=$(this).attr('id');
});
as you have written "how to find which id i have clicked". so to get the click id , you should use click event not keyup
$(".clsName").on('click',function () {
var getclickedID=$(this).attr('id');
});