JQuery Passing Array string -
i'm trying pass array .each jquery code, passing numbers 0, 1, 2, 3,... instead of string values.
my code define variable is:
var accessoriescats = [ 'beaded accessories', 'cufflinks', 'flip flops', 'floral accessories', 'foot jewelry', 'hair accessories', 'hankies', 'jewelry', 'leg garters', 'purses', 'shoe stickers', 'something blue', 'tiaras', 'totes' ];
here entire code:
<script> if (window.location.href.indexof("category-s/2022.htm") != -1) { var accessoriescats = [ 'beaded accessories', 'cufflinks', 'flip flops', 'floral accessories', 'foot jewelry', 'hair accessories', 'hankies', 'jewelry', 'leg garters', 'purses', 'shoe stickers', 'something blue', 'tiaras', 'totes' ]; $('#content_area > table:nth-child(6) > tbody > tr > td > table:nth-child(1) > tbody > tr > td > table > tbody').find('a').each(function(accessoriescats){ $(this).append('<span class="promo__text">' + accessoriescats + '</span>'); $(this).removeclass('smalltext colors_text').addclass('subcatrollover'); }); } </script>
basically want first .append is:
<span class="promo__text">beaded accessories</span>
but instead get
<span class="promo__text">0</span>
use this:
<script> if (window.location.href.indexof("category-s/2022.htm") != -1) { var accessoriescats = [ 'beaded accessories', 'cufflinks', 'flip flops', 'floral accessories', 'foot jewelry', 'hair accessories', 'hankies', 'jewelry', 'leg garters', 'purses', 'shoe stickers', 'something blue', 'tiaras', 'totes' ]; $('#content_area > table:nth-child(6) > tbody > tr > td > table:nth-child(1) > tbody > tr > td > table > tbody').find('a').each(function(i){ $(this).append('<span class="promo__text">' + accessoriescats[i] + '</span>'); $(this).removeclass('smalltext colors_text').addclass('subcatrollover'); }); } </script>
Comments
Post a Comment