Jump to content
php.lv forumi
  • 0

JQuery linka (a) selektesana


Blitz

Question

Atpuvenais kods un rezultāts:

html

<div id="thumbs">
<a href="./asdasdas.jpg" title="aaa" rel="vv">
 <img src="./asdasdas.jpg"/>
</a>
</div>

js

 

$(document).ready(function(){
$("#thumbs a")
.mouseover(function(){
  alert(this); //rezultats atgriez http://host/asdasdas.jpg
 });

});

 

1) visus citus elementus normāli var selektēt, bet selektējot a nevis atgriež objektu bet URLi. wtf?

2) ka elegantāk padot linka relatīvo URLi jquery apstrādei?

Edited by Blitz
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Tas this arī ir objekts. Tikai alerts rāda href daļu. Labāk izmanto firebug console.log() alert vietā

 

ja 2) punkā ar relatīvo URLi domāji to href, kas ir norādīts sourcē, nevis ar hostu klāt, pamēģini $(this).attr('href')

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...