html - jquery find next class in a list -


I know that this question has been asked for some time but none of the replies works, or less At least I've got it anyway.

After checking the input from the form input, I have to select the error class from the list item.

What do I have here:

html:

  & lt; Ul & gt; & Lt; Li class = "label" & gt; & Lt; Label & gt; Label & lt; / Label & gt; & Lt; / Li & gt; & Lt; Li class = "input" & gt; & Lt; Input name = "fname" type = "text" /> & lt; / Li & gt; & Lt; Li class = "icon" & gt; & Lt; / Li & gt; & Lt; Li class = "clearfix" & gt; & Lt; / Li & gt; & Lt; Li class = "error" & gt; & Lt; / Li & gt; & Lt; Li class = "label" & gt; & Lt; Label & gt; Label & lt; / Label & gt; & Lt; / Li & gt; & Lt; Li class = "input" & gt; & Lt; Input name = "lname" type = "text" /> & lt; / Li & gt; & Lt; Li class = "icon" & gt; & Lt; / Li & gt; & Lt; Li class = "clearfix" & gt; & Lt; / Li & gt; & Lt; Li class = "error" & gt; & Lt; / Li & gt; & Lt; Li class = "label" & gt; & Lt; Label & gt; Label & lt; / Label & gt; & Lt; / Li & gt; & Lt; Li class = "input" & gt; & Lt; Input name = "uname" type = "text" /> & lt; / Li & gt; & Lt; Li class = "icon" & gt; & Lt; / Li & gt; & Lt; Li class = "clearfix" & gt; & Lt; / Li & gt; & Lt; Li class = "error" & gt; & Lt; / Li & gt; & Lt; Li class = "label" & gt; & Lt; Label & gt; Label & lt; / Label & gt; & Lt; / Li & gt; & Lt; Li class = "input" & gt; & Lt; Input name = "password" type = "password" /> & Lt; / Li & gt; & Lt; Li class = "icon" & gt; & Lt; / Li & gt; & Lt; Li class = "clearfix" & gt; & Lt; / Li & gt; & Lt; Li class = "error" & gt; & Lt; / Li & gt; & Lt; / Ul & gt;   

jQuery:

  $ ('input [name = uname]'). ("Input", function () {var input = $ .trim (this.value); var BLIDRegExpression = / ^ [a-zA-Z0-9] + $ /; if (input == 0) {uname_status = False; $ (this) .closest ('li'). Next ('. Icon') .html ('& lt; img src = "/ assets / images / png / glyphicons_199_ban.png" / & gt;'); $ (This) .Parent ('li') Next () Next (). Next ('Li') Show (); $ (this). Spinach ('li') Next (). Next (). Next ('Li') .html ('& lt; span & gt; you must enter a username! & Lt; / span & gt;'); Return back;}});   

The above works , I was just thinking that there is a better way to choose "Error" class:

  $ (This). Parent ('li') Next (). Next () Next ('li') Show ();   

I have tried the following and they did not work:

  // The second stack overflow question $ (this) .clostest ('li' ) .nextAll (': (.error) is: first');; ( 'Error.') .. $ (This) .parents ('li') eq (0) .next () seems ('li.error'); // works but selects the next error square and after a $ ($) one .clostest ('li'). NextAll ('li.error'). Show (); Or $ (this). Parent ('Lee'). NextAll ('li.error'). Show ();   

Is there any other solution? Am I just missing something simple?

Try to get results and filter, such as:

 < Code> $ ('input [name = uname]'). ("Input", function () {...... $ (this) .parents (".input") .nextAll (".error") first () .html ('& lt; span & gt; You must enter a username! & Lt; / span & gt; ';)}}    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -