多个类使用Jquery映射并加载内容

时间:2013-05-24 10:13:38

标签: javascript jquery html css mobile

我有一个Div of Class

<div class='navigation five-icons'></div>

我想加载一个在其中返回html的URL,如何用jquery选择该div, 我试过的是

 $('.navigation .five-icons').load('URL');
 $('.navigation.five-icons').load('http://www.astuffaday.com/shot/menu.php');

但没用。

2 个答案:

答案 0 :(得分:0)

我不知道加载但你可以使用下面的代码来选择多个类

$('.navigation, .five-icons')

答案 1 :(得分:0)

您是否尝试异步获取数据? 使用$.post()$.get()

$.post('filename.php', {'name1':'value1', 'name2':'value2'}, function(result) {
   alert(result);  // result has the HTML content returned by filename.php
   $('#resultDiv').html(result);  // resultDiv will have its contents

   // Now you need to get only particular div
   // You can use 'find()'

   // Something like this may help  [Have not been tested]
   var data = $('result').find('.navigation .five-icons');
   alert(data);
})

<强>参考
$.ajax()
$.post()
$.get()
$.load()
.find()