Hello everyone, the first time asked a little nervous, I small white, look forward to common progress with everyone. The problem is, I'm going through a group of IMG that I want to take to the subscript of the current click IMG, I added a num attribute on the IMG to get the key for that element, how do I get the current img num?
{foreach from=$answers item=item key=key } {/foreach}这是遍历的img
//打印当前元素function selectImg(a){ console.log(a)}
I again Console.log (this.num) is undefined, all kinds of methods have been used, I now do not know how to obtain, seeking the guidance of the Great God.
Reply content:
Hello everyone, the first time asked a little nervous, I small white, look forward to common progress with everyone. The problem is, I'm going through a group of IMG that I want to take to the subscript of the current click IMG, I added a num attribute on the IMG to get the key for that element, how do I get the current img num?
{foreach from=$answers item=item key=key } {/foreach}这是遍历的img
//打印当前元素function selectImg(a){ console.log(a)}
I again Console.log (this.num) is undefined, all kinds of methods have been used, I now do not know how to obtain, seeking the guidance of the Great God.
This.getattribute ("num");
Try this.
Principle does not understand, directly with JQ to the IMG tag binding a Click event, get this is you click on the IMG, want to get what you use This.getattribute ("attribute");