簡體   English   中英

我的JavaScript遇到了一些問題

[英]Have some problems with my javascript

我的腳本有一些問題,我使用了JqueryUI工具提示,但它不起作用。 示例演示如下。

http://jsfiddle.net/VFZL7/

$(function() {
$("a[id*='product_wrap']").tooltip({
content: function(){return $(this).html().replace('150_','')},
track: true,
});
});

我希望工具提示指示圖像petplusvn.com/files/sanpham/16/150.jpg而不是petplusvn.com/files/sanpham/16/150_1.jpg

您可以使用正則表達式替換兩個URL(在src和data-original中)

$(function() {

    $("a[id*='product_wrap']").tooltip({

        content: function(){
            var $html = $(this).html().replace(/150_/g, '');
            console.log('new HTML: '+$html);
            return $html;
        },
    track: true,

    });
});

http://jsfiddle.net/7Y8Au/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM