blog.knym.net | I'm searching something to change my life.

jQueryでIMGタグを含んでいるAタグのborderの非表示

css; first-line: 0;">
a {
    color:#FFF;
            text-decoration:none;
            padding-bottom:1px;
}
    a:link,
    a:visited {
        border-bottom:1px dotted #FFF;
    }
    a:hover,
    a:active {
        border-bottom:1px solid #FFF;
    }


というCSS設定で<A>borderを表示するようにしていると、<A>の中に<IMG>タグを表示するときもborderが表示される。
それが嫌だったので、jQueryでそうならないようにした。



jQuery.noConflict();
(function($) { 
    $(function() {
        noLinkImgBorder();
    });
    function noLinkImgBorder(){
        $("img").each(function(){
            var parentTagName = $(this).parent().get(0).tagName
            if(parentTagName.toUpperCase()=="A"){
                $(this).parent().css("border","none");
            }
        });
    }
})(jQuery);

Related Posts

Write a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

Essentials

Meta

Pages

Categories