Thursday, 15 March 2012

javascript - Select needful class from string -



javascript - Select needful class from string -

i have class within body need select class hs-content-path-history-of-data-pagetopic2013

<body class="blog-template hs-blog-id-1815512257 hs-blog-listing hs-content-path-history-of-data-pagetopic2013 hs-blog-name-history-of-data-page"></boby> var bodyclass = $('body').attr('class'); // select needfull class var above if(selectedclass === 'hs-content-path-history-of-data-pagetopic2013'){ // works! }

how can select hs-content-path-history-of-data-pagetopic2013 body class?

to check if body, or element, has class, can utilize hasclass

if ( $('body').hasclass('hs-content-path-history-of-data-pagetopic2013') ) { ... }

javascript jquery string

No comments:

Post a Comment