1

I am developing app for android. but my img click function is not firing. Don't know why. The same works for div, but not for img. Any ideas why?

This is html code:

<img src="talk.png" id="talk" class="thumb3"/>

This is jQuery:

$("#talk").on('vclick', function () {
            alert("ItWorks!");                                                      
});

This is CSS:

.thumb3 {
        width:40px;
        height: 40px;
        margin-top:5px;
        z-index:999;
}

EDIT
tried with click and still not working.

1
  • 2
    @Satpal on touch devices(Phone) it is vclick event Commented Jun 11, 2014 at 11:24

3 Answers 3

2

Use ready function:

<script> 
    $(document).ready(function () {
        $("#talk").on('vclick', function () {
            alert("ItWorks!");
        });
    });
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

jQuery Mobile "vclick" event handler simulates the "onclick" event handler on mobile devices. @Anoop
@anoop please don't change the content. just format it!!
@Mr_Green it was his initial solution. I didnt change any of the content. May be after copying for the formatting, he should have changed to vclick again..
1

you have an typo error change vclick to click

$("#talk").on('click', function () {
        alert("ItWorks!");                                                      
});

Comments

1

Found the problem. Someone before me was inserted a div over the whole item with transparent background, so I removed the div and it worked fine. Don't know why would someone do that. This is why I don't like working on other people projects.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.