Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

finding an anchor with a certain attribute using jquery

I'm trying to find an anchor inside a div that posses a specific attribute, but the jquery code is for some looking at the hreef value of the anchor, not the anchor itself. This is the code I'm using:

<script type="text/javascript">
            $(document).ready(function() {
            $("#ax_campaign_nav a").each(function (i) {
                if (this.attr('data-ident') == "ax_models") {
                        this.hide();
                    }
            });
        });
    </script>

And my link looks like this:

<a href="javascript:void(0);" data-ident="ax_models" onclick="scrollToAnchor('#a_ax_models')">+ Model Bios</a>

What am I doing wrong? Thanks for the help.

like image 487
mheavers Avatar asked Feb 03 '26 13:02

mheavers


2 Answers

Try something like this:

$("#ax_campaign_nav a[data-ident=ax_models]").hide();
like image 121
Andrew H Avatar answered Feb 06 '26 02:02

Andrew H


$(this).attr("data-ident") and $(this).hide()

like image 30
Nick Jurista Avatar answered Feb 06 '26 03:02

Nick Jurista