EzDevInfo.com

click interview questions

Top click frequently asked interview questions

How do I programmatically click a link with javascript?

Hello is there any way to programmatically click on a link on my page using javascript?


Source: (StackOverflow)

How to trigger a click on a link using jQuery

I have a link:

<ul id="titleee" class="gallery">
  <li>
    <a rel='nofollow' href="#inline" rel="prettyPhoto">Talent</a>
  </li>
</ul>

and I am trying to trigger it by using:

$(document).ready(function() {
  $('#titleee').find('a').trigger('click');
});

But it doesn't work.

I've also tried: $('#titleee a').trigger('click');

Edit:

I actually need to trigger whatever get's called here <a rel='nofollow' href="#inline" rel="prettyPhoto">


Source: (StackOverflow)

Advertisements

jQuery: fire click() before blur() event

Good day!

I have an input field, where I try to make autocomplete suggestion. Code looks like

<input type="text" id="myinput">
<div id="myresults"></div>

On input's blur() event I want to hide results' div:

$("#myinput").live('blur',function(){
     $("#myresults").hide();
});

When I write something into my input I send request to server and get json response, parse it into ul->li structure and put this ul to my #myresults div.

When I click to this parsed li element I want to set value from li to input and hide #myresults div

$("#myresults ul li").live('click',function(){
     $("#myinput").val($(this).html());
     $("#myresults").hide();
});

Everything is going good, but when I click to my li blur() event fires before click() and input's value don't get li's html.

How can I set up click() event before blur()?


Source: (StackOverflow)

offsetTop vs. jQuery.offset().top

I have read that offsetLeft and offsetTop do not work properly in all browsers. jQuery.offset() is supposed to provide an abstraction for this to provide the correct value xbrowser.

What I am trying to do is get the coordinates of where an element was clicked relative to the top-left of the element.

Problem is that jQuery.offset().top is actually giving me a decimal value in FFX 3.6 (in IE and Chrome, the two values match).

http://jsfiddle.net/htCPp/ exhibits the issue. If you click the bottom image, jQuery.offset().top returns 327.5, but offsetTop returns 328.

I would like to think that offset() is returning the correct value and I should use it because it will work across browsers. However, people obviously cannot click decimals of pixels. Is the proper way to determine the true offset to Math.Round() the offset that jQuery is returning? Should I use offsetTop instead, or some other method entirely?


Source: (StackOverflow)

$(document).click() not working correctly on iPhone. jquery

This function works perfectly on IE, Firefox and Chrome but when on the iPhone, it will only work when clicking on a <img>. Clicking on the page (anywhere but on a img) wont fire the event.

$(document).ready(function () {
  $(document).click(function (e) {
    fire(e);
  });
});

function fire(e) { alert('hi'); }

The HTML part is extremely basic and shouldnt be a problem.

Any ideas?


Source: (StackOverflow)

Android: Disable highlighting in GridView

How can I turn off the orange highlight when clicking an item in a GridView?

I haven't been able to find a solution in the documentation or through testing.


Source: (StackOverflow)

Can i click a button programmatically for a predefined intent?

I need the button click of the intent ACTION_SEND.. Here there is no need of displaying UI.. Can i get the "Send" button click from the MMS-SMSProvider in android??

Kindly help me!!

Thanks


Source: (StackOverflow)

How to create an HTML checkbox with a clickable label

How can I create an HTML checkbox with a label that is clickable (this means that clicking on the label turns the checkbox on/off)?


Source: (StackOverflow)

jQuery Button.click() event is triggered twice

I have the following problem with this code:

<button id="delete">Remove items</button>

$("#delete").button({
     icons: {
             primary: 'ui-icon-trash'
     }
}).click(function() {
     alert("Clicked");
});

If I click this button, the alert show up two times. It's not only with this specific button but with every single button I create.

What am I doing wrong?


Source: (StackOverflow)

Is there an equivalent to e.PageX position for 'touchstart' event as there is for click event?

I'm trying to get the X position with jQuery of a touchstart event, used with the live function?

I.e.

$('#box').live('touchstart', function(e) { var xPos = e.PageX; } );

Now, this does work with 'click' as the event. How on earth (without using the alpha jQuery Mobile) do I get it with a touch event?

Any ideas?

Thanks for any help.


Source: (StackOverflow)

Using jQuery to programmatically click an link

I know this question has been asked before, but after a search on the web I can't seem to find a straight forward answer.

the HTML

<a id=myAnchor rel='nofollow' href=index.php>

the jQuery (Both of these do not work)

 $('#myAnchor').click();

or

$('#myAnchor').trigger('click');

What is the simplest and most efficient way to achieve this?


Source: (StackOverflow)

How to stop default link click behavior with jQuery

I have a link on a webpage. When a user clicks it, a widget on the page should update. However, I am doing something, because the default functionality (navigating to a different page) occurs before the event fires.

This is what the link looks like:

  <a rel='nofollow' href="store/cart/" class="update-cart">Update Cart</a>

This is what the jQuery looks like:

   $('.update-cart').click(function(e) { 
         e.stopPropagation(); 
         updateCartWidget(); 
      });

What is the problem?


Source: (StackOverflow)

Difference between .on('click') vs .click()

Is there any difference between $('#whatever').on('click', function() and $('#whatever').click(function() ?


Source: (StackOverflow)

Android - ListView - performItemClick

I'm facing some difficults when I try to use the performItemClick funcion of the ListView.

All I want to do is to perform a click programatically in the first item of the list.

How can I do that? I looked up that function in the documentation, but I didn't really understand its parameters.

I tried something like:

 myListView.performItemClick(myListView.getChildAt(0), 0, myListView.getChildAt(0).getId());

But it didn't work (myListView.getChildAt(0) returns null)

Thank you in advance!


Source: (StackOverflow)

jQuery bind click *ANYTHING* but *ELEMENT*

Say there are some elements floating around, and I'm trying to do some when I click ANYTHING(divs, body, whatever...) but the one specified (e.g. div#special).

I'm wondering if there's a better way to achieve this besides the following method I can think of...

$(document).bind('click', function(e) {
    get mouse position x, y
    get the element (div#special in this case) position x, y
    get the element width and height
    determine if the mouse is inside the element
    if(inside)
        do nothing
    else
        do something
});

Source: (StackOverflow)