[solved] jquery how to get attribute of clicked link? |
[eluser]SPeed_FANat1c[/eluser]
Here is the link. Code: <a class="del" href="" filename="naujiena11.jpg"><img src="http://localhost/darzelis/images/admin/delete.png"></a> It has class "del" and attribute "filename". Code: $('a.del').live('click',function(){ ![]() I cannot use $('a.del') to select, because there is more links with the same class, I want to select which is clicked.
[eluser]Eric Barnes[/eluser]
Well for one filename is not a valid attribute to the a tag so I do not believe that will even work. As a workaround you could do something like: Code: <a class="del" href="" id="file_1"><img src="http://localhost/darzelis/images/admin/delete.png"></a>
[eluser]SPeed_FANat1c[/eluser]
I use values from id's but this time decided to make my own attribute so it would look nice ![]() ![]()
[eluser]cideveloper[/eluser]
I understand this is a solved topic but just to clarify things you can now start using custom data atrributes according to the HTML5 specs. So you can use an attribute like data-filename. The custom attribute must be prefixed with "data-" Read more here. that way you could use Code: $('a.del').live('click',function(e){
[eluser]SPeed_FANat1c[/eluser]
There is absolutely no problem that it is solved, thank you ![]()
[eluser]Eric Barnes[/eluser]
@progra@mmer - Any idea if that is supported in most browsers? Or is that only available to newer news? Specifically ie6/ie7?
[eluser]cideveloper[/eluser]
I have tries it in IE7, IE8, IE9 Beta, various flavors of FF, and Chrome with no problems. I have stopped supporting IE6 and do not even have access to that browser. I know this may sound elitist but people need to upgrade their ancient browsers and I tell them that. I mean really that browser was released August 27, 2001.
[eluser]Eric Barnes[/eluser]
Yea I don't disagree. Just curious for the most part. ![]() |
Welcome Guest, Not a member yet? Register Sign In |