2015-05-25 16 views
0

我有兩個不同的頁面,我正在使用。其中一個沒有這個問題,另一個沒有問題。問題是我有span標記,我有一個類用於檢測變化並執行操作。例如關於手機上發生的Jquery問題發生在一個頁面上,而不是另一個

$(document).ready(function() { 
    $(document).on("click",".test",function(){ 
     $(this).html("changed"); 
    });  
}); 

<!DOCTYPE html> 
<head> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Invoice Management</title> 
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> 
    <script src="http://hayageek.github.io/jQuery-Upload-File/jquery.uploadfile.min.js"></script> 
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> 
    <script src="Scripts/controlscript.js"></script> 
</head> 
<span class="test" style="background-color:red;">Hello</span> 

因此,單擊具有測試類的跨度標記應更改要更改的文本。這在我的電腦上工作得很好,但當我在移動設備上嘗試時,它什麼也不做。陌生人的問題是,我有另一個頁面,我用鏈接相同的方法,它工作得很好。任何想法爲什麼會發生這種情況?

+1

加上'$(文件)。就緒(函數(){'腳本在''作爲要添加的jQuery的lib頭,但增加的頭。 –

+0

@Bhushan Kawadkar前的腳本標籤,他已經顯示出他的代碼結束。不像現在這樣,因爲他不能在沒有腳本標記的情況下執行它。 – PHJCJO

+0

@PHJCJO,是的,可能是你的權利,但我只是想過如果是這樣的話 –

回答

0

首先您發佈的代碼結構不完整。要使用任何js庫函數,首先需要在使用該庫中定義的任何函數之前加載該js庫。

例如:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> ----> keep this line first 


$(document).ready(function() {}); -----> next to the above line 
+0

如果我將標記更改爲標記而不是跨度,則腳本可以正常工作。 – user541597

+0

這是什麼意思? –

+1

如果我將此行更改爲標籤而不是其工作範圍。 你好 user541597

相關問題