javascript - Jquery select first letter? -
I'm just trying to get jquery to identify the first letter of a paragraph. How do I do this?
For example, I have many paragraphs on the page. Only the articles that start with a special letter would like to be hidden "current" and everyone else, I know very well how to add and hide the class, but I do not get jquery to recognize the first letter can.
Second, is it possible to drag the 'first letter' variable in the Url string?
For example, Page 1 - is a list of letters that the user clicks on the 'B' and the URL
and page 2 The variable that raises (B) and applies it to junkie, shows only those paragraphs
Try:
jQuery ('p'). Substr (0,1) .toUpperCase () == 'B') {jQuery (this) .addClass ('someclass'}}})
You can use PHP to clean up the variable and print in JS:
& lt; Script type = "text / javascript" & gt; Var characters = '& lt ;? Php echo (strlen ($ _ GET ['letter']) == 1)? $ _GET ['Letter']: ''; ? & Gt; '& Lt; / Script & gt;
Or just remove it by holding it document.location
.
Comments
Post a Comment