开发者

external link icon

开发者 https://www.devze.com 2023-02-18 08:22 出处:网络
Using a script, that works great. It pops i开发者_运维百科n a external link icon next to external links. Whoopydoo... and also adds a target=\"_blank\" attribute.

Using a script, that works great. It pops i开发者_运维百科n a external link icon next to external links. Whoopydoo... and also adds a target="_blank" attribute.

The issue I have is, I dont want it to work on IMAGES.

Only on text links , so any sugestions.

The jquery is:

(function(a){
a.fn.link_external_icon=function(p){
    var p=p||{};
    var icon_path=p&&p.icon_path?p.icon_path:"link_external.png";
    var n=a(this);
    n.find("a[target='_blank']").css("padding-right","13px").css("background-image","url("+icon_path+")").css("background-repeat","no-repeat").css("background-position","center right");
}

})(jQuery);

The Script is:

<script language="javascript" type="text/javascript">
        $(function() {
            $("body").link_external_icon({
                icon_path:"../images/link_external.png"
            });
        });
    </script>

Image is:

external link icon

Any help appreciated.

Original code is: http://htmldrive.net/items/show/161/Link-external-icon-jQuery-plugin-for-show-external-linktarget_blank-icon.html


Change your selector to...

n.find("a[target='_blank']:not(:has(img))");

jsFiddle.

Your plugin, modified

(as per requested in comments.)

(function(a){
a.fn.link_external_icon=function(p){
    var p=p||{};
    var icon_path=p&&p.icon_path?p.icon_path:"link_external.png";
    var n=a(this);
    n.find("a[target='_blank']:not(:has(img))").css("padding-right","13px").css("background-image","url("+icon_path+")").css("background-repeat","no-repeat").css("background-position","center right");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消