English 中文(简体)
jj 查询导入 jQuery
原标题:jQuery importing jQuery

I have an HTML page with jQuery inside and JavaScript. I m importing the libraries I need in the head tag:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places" type="text/javascript"></script>

然后我进口一些带有jQuery的 html 里面:

$( #cliente ).click(function(){$( #container ).load( /clienti/cliente );});

但装入的页面中的jQuery 无效 。 (我肯定代码正确,

I need to do something? I have tried to import the libraries in the imported page before the script (out of the head), but not working. I haven t other ideas!

最佳回答

< a href=> "http://api.jquery.com/load/" rel="nofollow"\\\\\ code>.load () 只对 HTML 有用(见题为“Script detail”的一节) 。 它不会评价您装入的 HTML 中的任何脚本。 您想要的是使用后缀装入它, 即 。

$( #cliente ).click(function(){$( #container ).load( /clienti/cliente.html );});
问题回答

如果JS和HTML必须在同一档案中,

$( #cliente ).click(function(){
    $.get( /clienti/cliente , function(data){
        $( #container ).html(data);
    });        
});

或者,您也可以将两个项目(HTML和JS)作为文本通过。

$( #cliente ).click(function(){
    $.getJSON( /clienti/cliente , function(object){
        $( #container ).html(object.html);
        $parseJSON(object.jscript);
    });        
});

否则,您需要使用 $.get () $.getJSON () 来两次获取 html 和 js 。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签