JQuery :: Event.target - Click Anchor As Matched Element
Jun 1, 2010
consider the following code;
$("#content").click(function(event)
{
if($(event.target).is('a'))
{
$(this).//do something
}
}
I'm binding a click event to a div so that I can see whether is was the div or some element inside the div that has been clicked. When the if() in my code evaluates to true $(this) is still equal to $("#content") whereas I'd like to have the clicked anchor as matched element. How would I do this?
View 2 Replies
ADVERTISEMENT
Jun 10, 2009
I'm confused as to why when I have:
$('a').click(function(){
alert(this);
return false;
[code]....
View 4 Replies
View Related
Jan 24, 2011
I want to call the click event of the link (anchor tag) on the click of the button. I used this code below in the click event of button to call links click event and it works fine in IE.
document.getElementById('linktag').click();
But, this doesn't work in Firefox. I googled a bit and found that in firefox, you have to do something more to achieve this behaviour. So, I ended up doing this on button click to work in firefox:
var link=document.getElementById('linktag');
var e = document.createEvent('MouseEvents');
e.initEvent(
[code]....
The above code does the click on link when I click on the button. But my problem now is that I have defined a link as
<a href="mailto:abc@xyz.com?subject=abc&body=email body">email </a>
and when click is called and mailto links opens my email client, it somehow ignores the subject and body parameters of the link. It works properly when i actually click a link element. but it doesn't work when i simulate the click event by code written above. above dispatching event code somehow ignores the link parameters?
View 3 Replies
View Related
Jul 16, 2009
When I load the page the div #forgot_login blindes down even though I did NOT click the anchor link. Also, clicking the anchor link does not toggle it up and down. The event binding is not working.
HTML
<a href="#" id="forgot_login_link" title="Show">Show</a>
jQuery Event
$("#forgot_login_link").click(show_hide($("#forgot_login")));
Here is the show/hide code:
function show_hide(p_Element) {
p_Element.toggle('blind', { direction: "vertical" }, 500);
}
View 1 Replies
View Related
Jul 26, 2007
We are developing an Ajax based application. In this application the
URL is fixed and as user navigates on the application we will change
Anchor on the URL so that user can bookmark the url and can load the
page on demand.
When user refreshes the page we have no issue in the populating the
page based on the anchor in URL as on load we can capture the
hash(#anchor) and act accordingly.
sample URL: http://www.google.com/somecontext#<anchor>
When the user clicks back button anchor is changing but not able to
know where to get callback.
Is there any event or way I can find when the user has clicked back
button.
View 2 Replies
View Related
Feb 22, 2010
I'm a starter in using jQuery and I decided to work my way through the 'Learning JQuery' book from packt.Somewhere in Chapter 5 they use the clone() function with the false attribute. The JQuery version used in the book is 1.1.3a. With the clone(false) method the writer can clone only the matched element and not the descendants. And that works in 1.1.3a.I know that this is no longer the case in JQuery 1.4. Boolean is only for Event Handlers.But what is the new equivalent of this method? In other words. How can I clone an element with only the matched element and not it's descendants?
View 2 Replies
View Related
Mar 24, 2011
I know you can use :even or :odd to get the even or odd indexes from a set, or :lt/:gt to filter down the matched set before/beyond the specified index. But what if I want to select every 5th element? And I know it's not nth-child, because that selects everything that is the nth-child of it's parent and not if it is one of the nth elements in the matched set. Is the only way to use .each(function (index) {...}); and then check if the index makes that element one of the nth items?
View 2 Replies
View Related
Jul 29, 2011
I`m trying to make selecting an select list option (as it become when we click on it)by clicking on a special pseudo element.I`m trying to do it in this way:
<script>
$(document).ready(function(){
$(".psevdo-checkbox").each(function(){
$(this).click(function(){
[Code].....
View 6 Replies
View Related
Jul 25, 2010
I've got a scenario where i've got a list of text names on a page and a rotating gallery of images. Each image relates to one of the names. What i would like to do is highlight the name by adding a css class or id when the related image comes into focus.
I'm sure i can do this by using the rel element to relate to the id of the image (or the other way round!) but i'm not sure exactly how. I presume it's using jquery live and matching with selectors.
I'm using jquery and the galleria plugin.
View 2 Replies
View Related
Oct 16, 2010
Okay I have a div element which has a click event for deleting it but I also have sub li elements with click events for deleting them, problem is if I click a sub element the click event is also triggered for the parent how can I ensure it only triggers on the topmost visible element?
View 1 Replies
View Related
Jul 30, 2010
please see the code below.at the moment, when you click img, click eventtriggeredbecause parent element has click event.I want click event not to be triggered when you click img.How would I do that?
$("#click1").click(function(){
alert('Clicked.');
});
[code]....
View 2 Replies
View Related
Jan 12, 2010
I'm writing some code which requires me to copy the click event from one element to anotherI have a div with an onclick event. I need to copy this event to another div to replicate the behavior of the first.
View 7 Replies
View Related
May 28, 2010
I have a function where I want to add a sibling element to each of the elements and trigger a click on each of them right away. Here's what I have so far:
$(function(){
$('#articles').delegate('.click-link','click',function(){
$(this).toggle(
function(){
alert('toggle one');
},
function(){
alert('toggle two');
});
});
$('.toggle').each(function(){
$(this).after('<span class="click-link">Hide</span>');
$(this).next().trigger('click');
});
});
For some reason the toggle doesn't get triggered. If I put something in the function right before the toggle, it fires on page ready. However, the toggle doesn't fire. toggleClass does, though. What can be causing this?
View 4 Replies
View Related
May 5, 2009
I found a nice script over at jQuerry for Designers that I'm using in a Drupal site. It seems to work fine, except for that every anchor tag on the page triggers the script! how can i adjust the script to target a specific anchor (currently has an ID of "test") and ignore all other anchor tags? here's the script, its placed in an external .js file:
[Code]....
View 4 Replies
View Related
Dec 2, 2010
Code:
This is a trimmed down version of my problem, '.myElement' gets duplicated on double click. In '.myElement' is content and a close button that when clicked removes itself.
The problem is "newly" created elements don't get the the dblclick or the child 'a.close' click events. i know i can double the events and re apply after the element is created but in my real version there is WAY more going on in each of these events and i don't want to create all that redundant code. i guess i can pull all the actions out into functions and bind after creation but even that is a little messy, is there an apply events feature in jQuery or something?
like:
Code:
View 1 Replies
View Related
Jul 20, 2005
I was wondering if it is possible to target a named anchor in a frame when
opening a new window with a javascript function? has anyone actualy been
able to do this?
View 1 Replies
View Related
Sep 30, 2011
I am trying to redevelop firefox addon, to give it more funcionality. I found JS file where all the functions are and started to edit it.
What I want to achieve is to get target of an anchor under mouse pointer (when mouse pointer is over anchor, I right click and call addon from context menu).
For example when I have anchor which HTML code is:
<a href="somewehere.com/place">place</a>
when I right click on this code and call my addon I would like to alert its href (somewehere.com/place)
I wrote a function:
function ff()
{
var current_target=this.href;
alert(current_target);
}
but it gives me udefined on alert
[URL]
View 2 Replies
View Related
Sep 30, 2011
I am trying to redevelop firefox addon, to give it more functionality. I found JS file where all the functions are and started to edit it.
What I want to achieve is to get target of an anchor under mouse pointer (when mouse pointer is over anchor, I right click and call addon from context menu).
For example when I have anchor which HTML code is code...
View 7 Replies
View Related
Feb 1, 2011
I have a js(using jQuery lib) file where all events and following actions(functions) are written. For one of such events there is a function that prepends one more similar element from which prepending was called:
$("#id1").click(function(){
$(...).before("<div id='id1'></div>");
});
so that when I will click to just prepended element one more element should be prepended and so on.The problem is that when new element is prepended, click event doesn't work on it. jQuery doesn't recognize it, like doesn't see it.
View 2 Replies
View Related
Mar 31, 2010
i am working on a custom drop down list that has hidden #options DIV which is shown when the user clicks on a button. the problem i am having is that the click event does not seem to be attached to the LI elements since they are hidden when the page first loads. if i show the #options DIV when the page loads everything is working as expected.i've tried to attach the click event after i show the hidden UL but that didn't work either.what can i do to make sure the LI click event fires? i tried to put A tag inside of LI and attach click to that but to no avail.
<style type="text/css">
.gbtn-options {
overflow-y:auto;[code]....
View 6 Replies
View Related
Jul 23, 2005
Does someone can help me with the following problem?
I have a SELECT form tag, with some OPTIONS elements. I am using the
following code to detect a click in the SELECT.
....
document.onclick = fnc_document_click
....
function fnc_document_click(){
if(window.event.srcElement.id == "my_lst"){
......
}
}
How can I avoid the "if" if user click in a area of SELECT out of the
options elements? (The SELECT object is higher than the the goups of
OPTIONS its contains)
In other words, how can detect if the click Iinside the SELECT element)
happens in a OPTION element or not?
View 1 Replies
View Related
Sep 3, 2010
I have Cycle "pager" navigation working flawlessly in one of my pages. What i'm trying to do is this:
I'm Attempting to LINK to specific Anchors from a link on a different page.
Example:
// external page link //
<a href="http://www.convertstyle.com/beta/apparel/womens-apparel#shirt1">Headline Womens</a>
[Code]....
View 1 Replies
View Related
Dec 19, 2009
I'm just trying to register a simple click event onto a input element with addEventListener and attachEvent... My code:
[Code]...
View 2 Replies
View Related
Sep 15, 2009
I would have wished it under better circumstances. However, I'm having a quite annoying problem. I'm using jQuery UI hide effect and for some reason it messes with the DOM and/or and completely messes up some of my controls.$('#dvucCustomization').hide('fold', {}, 500);Is that the correct way to call the hide effect on a DIV element?I also tried simply:$('#dvucCustomization').hide('fold');and the same result: the JSs I have in the hidden/shown element are not working any more.
View 6 Replies
View Related
Nov 22, 2010
I have a problem with my jquery. This is my code:
jQuery(function(){
jQuery(".class1").toggle(function(){
jQuery(this).animate({ height: 250 }, 'slow');
jQuery(".class12",this).animate({ height: 250 }, 'slow');
[Code].....
So div.class1 wil animate from 100px to 250px if it's clicked. However, I couldnot click the link inside this div. Everytime i click it will be animated to 100px, and I can never get the link.
How can I keep the div.class1 open so that I can click on the link??
View 1 Replies
View Related
Apr 19, 2010
I'm just starting out, and having a little difficulty understanding how to target other html markup around a certain 'on click' item.[code]So when the user clicks the anchor the text is inserted into the following textarea. I achieved this by:[code]
View 2 Replies
View Related