Created
July 11, 2013 11:12
-
-
Save umidjons/5974576 to your computer and use it in GitHub Desktop.
* Change state programmatically with trigger() // hover, focus, active, visited
* Build reqular expression on the fly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function () { | |
var myElem = $('a.myClass'), | |
txt="hello", | |
longText="some very very long text with /hello/world/, wow", | |
pattern = '\/' + txt + '\/',// build regexp pettern on the fly, pattern=/\/hello\// | |
rx = new RegExp(pattern, 'i'); // create regexp object | |
if (rx.test(longText)) { // test - is there /hello/ in longText? | |
myElem.trigger('hover'); // if there is, change state of the <a class"myClass"> to <a class"myClass:hover"> | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment