Tag: 分裂

最后一次斜线后jQuery .split()?

我无法在.split()上找到太多文档,我有一些代码可以在单击两个单独的按钮时更改图像的来源以及图像的目标文件夹。 一个按钮更改源文件夹,另一个按钮更改实际的jpeg名称。 我的脚本运行正常,但现在它正在运行,它是多个文件夹深,当我点击更改文件夹时,默认图像隐藏/不显示最后一个/之后的实际jpg,直到我点击另一个按钮。 我有的jquery如下: $(document).ready(function(){ siteUrl = ‘http://webdev.timberwindows.com/wp-content/themes/TimberWindows/images/window-planner/’; imgFldr = ‘period-black’; //on hovering the 21 or 24 colour options, change the colour of the image but not the folder $(‘#black’).click(function(){ $(“#pic”).attr(“src”,siteUrl+imgFldr+”/black.jpg”); }); //click the hardware buttons and change the folder where the images are coming from, but not the image itself (by name) $(‘#standardBlack’).click(function(){ $(“#pic”).attr(“src”,’standard-black/’+$(“#pic”).attr(“src”).split(‘/’)[1]); […]

AJAX / JQUERY – 拆分返回的数据并放在两个单独的div中

我目前正在使用以下代码每10秒运行一次AJAX查询来填充 setInterval(function(){ $.ajax({ url: “ajax.php”, type: “GET”, cache: false} ).done(function(html) { $( ‘#datacontainer’ ).html( html );});},10000 ); 我现在已经设置了ajax.php文件以返回一个字符串,该字符串现在包含我要拆分的分隔符’—-‘并填充两个div。 当分割data[0]进入 并且data[1]进入 时,我想分成data[] 如何修改此代码以实现此目的?