开发者

Click between the lines

I have multiple defined as:

<a href="col_c.php?id=1&field='A'" target="Frame3">item A</a>

and also I have a jquery script:

$(".item"开发者_如何学编程).click(function(){ itemclick(this); });

When a user positions the mouse between the items where the link is not active the itemclick() is executed without the link redirect.

How I can prevent this from happening?

Thanks


You don't show everything. It seems those links are inside other tags with class "item". So of course, if someone clicks outside a link but inside of that parent there won't be a "href" available to the function. There are several options, one would be to just not do anything if the clicked object is not a link <a ...>.


Give your links a class like:

<a class="link" href="col_c.php?id=1&field='A'" target="Frame3">item A</a>

and then use

$(".link").click(function(){ itemclick(this); });

I assume your .item is a div layer or a table row so it is also triggered around your link.


Simply execute the function only on the links themselves, not the whole parent (I expect your links are the children of something called .item).

$(".item a").click(function(){ itemclick(this); });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜