Javascript examples for String Operation:String Character
Get Exact Class Name That Starts With Certain Characters
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> <script type="text/javascript"> $(window).load(function(){// w ww. j ava 2 s.com var $cn = $('[class^=bg]').prop('class'); console.log($cn.split('bg-')[1]); }); </script> </head> <body> <div class="bg-green"> This is my green Div </div> </body> </html>