2014-01-30 37 views
0

有一個網站叫做lipsum.com,它會生成隨機文本。我正在嘗試使用jquery生成一個單詞並將其保存到一個變量。我發現這[1]:http://sanderkorvemaker.nl/jquery/jLorem.php這可能是很好,但我不知道爲什麼它不工作。基於我已經想出解決方案的例子,我在我的解決方案下有一個名爲「腳本」的文件夾中的JavaScript文件,但我仍然沒有得到任何輸出到屏幕上。JQuery Lipsum生成器不生成字

這裏是我的代碼: 「文字」

<!DOCTYPE html> 

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title></title> 
    <script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"</script> 
    <script src="Script/jquery.lorem.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
      $(document).ready(function() { 
       $('.ipsum').lorem({ type: 'paragraphs', amount: '4', ptags: true }); 
      }); 
    </script> 
</head> 
<body> 
<div class="ipsum"></div> 
</body> 
</html> 
+1

'$('。ipsum')'不匹配任何東西。 –

+0

.ipsum是什麼意思?它是在尋找一個參考嗎? – user977154

+0

添加到車身標籤內。 $('。ipsum')正在尋找一個類'ipsum'的元素 – Josh

回答

2

添加一個div一類的

<!DOCTYPE html> 

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title></title> 
    <script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script> 
    <script src="Script/jquery.lorem.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
      $(document).ready(function() { 
       $('.ipsum').lorem({ type: 'paragraphs', amount: '4', ptags: true }); 
      }); 
    </script> 
</head> 
<body> 
    <div class="ipsum"></div> 
</body> 
</html> 
+0

不幸的是我沒有得到任何輸出。 – user977154

+0

我忘了一個引號(文本編輯器通常爲我做,嘿)。嘗試像

Josh

+0

仍然沒有得到任何輸出。我有我的html文件,然後我有一個名爲腳本 – user977154