在我的移動應用程序中,我需要在網頁上移動一個綠色圖像。 當綠色圖像懸停在提交按鈕上時,該按鈕將顯示「提交?」,並且當用戶在提交按鈕上掉下綠色圖像時,該按鈕將變爲橙色。jQuery Mobile:如何檢測一個移動圖像懸停在按鈕上
這裏的圖片:
問題是,當在按鈕上的綠色形象懸停,按鈕無法改變,只有當我觸摸按鈕,它可以改變。我試過hover()和mouseover()方法,都沒有工作。這是jQuery Mobile,在我的PC版本中,一切工作都很好,但移動應用程序是不同的。
那麼,我該怎麼做,以便當綠色圖像懸停在按鈕上時,它可以顯示「提交?」?或者有什麼方法可以檢測到物體是綠色的圖像時,是否或否按鈕?
這裏是代碼:拖放方法來自另一個JS文件,但不應該影響這個問題。
id = "html";
$(id).ready(function (e) {
$('.yes').bind('mouseover', function(event, ui){
$('.yes').attr("src","images/submit_confirm.png");
$('input[name=stimulusResponse]').val("yes");
$('.no').attr("src","images/no.png");
});
$('.no').mouseover(function(event, ui){
$('.no').attr("src","images/submit_confirm.png");
$('input[name=stimulusResponse]').val("no");
$('.yes').attr("src","images/yes.png");
});
$('.bottomGoButton').drag(function(ev, dd){
$(this).css({
top: dd.offsetY,
left: dd.offsetX
});
$(this).bind('vmousemove', function(event) {
$('input[name=test]').val(event.pageX + ", " + event.pageY + $('input[name=test]').val());
});
});
$('.no').drop(function(){
$('input[name=stimulusResponse]').val("no");
$('.no').attr("src","images/submitted_no.png");
});
$('.yes').drop(function(){
$('input[name=stimulusResponse]').val("yes");
$('.yes').attr("src","images/submitted_yes.png");
});
});
顯示一些代碼。 – Omar
@Omar附加代碼 –
用'$(document).on('pageinit',function(e)' – Omar