is not clicked in html using jquery
I am new to jquery, I have a problem. I want to check the not condition on html element 开发者_StackOverflow中文版using jquery, like this, any help will be awesome
if(("#id")!clicked())
{
alert("must clicked");
return;
}
not to sure what you're after but try this. Add an onclick attribute to the you element and the below js.
html:
<img src="abc.jpg" onclick="is_clicked=true;" />
js:
var is_clicked = false;
... you code here ...
if(!is_clicked) {
alert("must clicked");
return;
}
I would suggest that you rework on your solution.
I am sure we can check that this element was clicked/checked in better ways. If it is dropdown, we can test if any valid value is selected. If it is a checkbox then we can test if it is checked.
Well I don't think you would be able to check if you can check if image element was clicked or not .... please if anyone does improve me!!
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery."></script>
<script>
var flag = false;
function click(){
flag = true;
}
function check(){
if(flag == false)
{
alert("Image was not clicked");
}
else{
alert("Image was clicked");
}
}
</script>
<img id="img" src="http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs744.ash1/163661_10150382342455319_722950318_17002228_7386702_n.jpg" onclick="click()"></img>
<input type="button" onclick="javascript: check()" value="check"/>
精彩评论