选择一个 xHTML 标签并使用 jquery 将其属性存储到数组中

发布于 2024-12-03 23:03:46 字数 788 浏览 0 评论 0原文

我如何使用jquery todo: 1-读取特定的URL 2-将特定的xhtml标签值存储到数组中 3-将此数组传递给PHP脚本

这些是上面标签中的标签

<img class="nytmm_slidingMultimedia_imageSlide" style="display: inline; height: 620px; width: 930px;" src="http://graphics8.nytimes.com/images/2011/02/28/world/africa/20110301_LIBYA-slide-FBZQ/20110301_LIBYA-slide-FBZQ-jumbo.jpg">

我想将src列表存储到数组中(可能有具有不同src的img标签)

<div class="nytmm_bigPhotoGallery_caption">Residents of Sabratha rallied in support of Colonel Qaddafi in front of a bank where they were waiting to receive a one-time 300 Dinar bonus offered to every Libyan citizen by the regime.</div>

在上面标签中我想存储值或文本将 div 内的内容放入另一个数组中 (可能有不同内容的 div 标签)

然后我想将这 2 个数组传递给 php,在那里我可以设法完成其余的任务。

谢谢和问候

how can i use jquery todo:
1- read a specific URL
2- store a specific xhtml tag values into an array
3- pass this array to PHP script

these are the tags

<img class="nytmm_slidingMultimedia_imageSlide" style="display: inline; height: 620px; width: 930px;" src="http://graphics8.nytimes.com/images/2011/02/28/world/africa/20110301_LIBYA-slide-FBZQ/20110301_LIBYA-slide-FBZQ-jumbo.jpg">

in the above tag i want to store a list of src into an array ( there are may img tags with different src )

<div class="nytmm_bigPhotoGallery_caption">Residents of Sabratha rallied in support of Colonel Qaddafi in front of a bank where they were waiting to receive a one-time 300 Dinar bonus offered to every Libyan citizen by the regime.</div>

in the above tag i want to store the value or the text inside the div into another array
( there are may div tags with different content )

then i want to pass those 2 arrays to php where i can manage to do the rest of the tasks.

thanks and regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潇烟暮雨 2024-12-10 23:03:46
var requestData = {}; // data object for future ajax request
requestData.src = []; // array for storing your src values
// getting multiple src values
$('.nytmm_slidingMultimedia_imageSlide').each(function(index){
  requestData.src.push($(this).attr('src'));
});
// getting single div text, be sure that there is only one div selected
requestData.text = $('.nytmm_bigPhotoGallery_caption').first().text();
// make an ajax request
$.post( 'some/handler.php', requestData, function(response) { console.log(response)} );

只有一些关于如何获取单个值和乘法的示例。

var requestData = {}; // data object for future ajax request
requestData.src = []; // array for storing your src values
// getting multiple src values
$('.nytmm_slidingMultimedia_imageSlide').each(function(index){
  requestData.src.push($(this).attr('src'));
});
// getting single div text, be sure that there is only one div selected
requestData.text = $('.nytmm_bigPhotoGallery_caption').first().text();
// make an ajax request
$.post( 'some/handler.php', requestData, function(response) { console.log(response)} );

There is only some examples of how to get single value and multiply.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文