Receive message "Expected", "or" {"but found" [selector] "

Receiving the message "Expected", "or" {"but found" # 44559 ". My code is as follows:

var valueid = $("div#center-box div#empid-textbox input").val(); //valueid=44559
if($("div#esd-names li#" + valueid).length > 0){
   //DO SOMETHING;
};

I get the value of what is entered in the text box input field, which in the case of "44559" cannot understand why I am getting this error.

I call my function to get the value with the following code. After you press ENTER in a specific text field, the value of the text field will be retrieved and launched with the list items to see if it exists ... if that happens - // DO SOMETHING //

$("div#center-box div#empid-textbox input.id").keypress(function(e){
  key = e.which;
  if(key===13){
    valueid = $("div#center-box div#empid-textbox input").val();
    if($("div#esd-names li[class*='" + valueid + "']").length > 0){
       //DO SOMETHING;
    };
  };
});
+3
source share
3

. .

+5

? ?

*/********* EDITED **********/*

, , :

HTML:

<div id="center-box">
            <div id="empid-textbox">
                <input type="text" class="id" />
            </div> 
        </div>
        <div id="esd-names">
            <ul>
                <li class="1">John Doe</li>
                <li class="2">Jane Doe</li>
                <li class="4">John Smith</li>
                <li class="8">Jane Smith</li>
            </ul>
        </div>

JavaScript:

$(document).ready(function()
{
                $("div#center-box div#empid-textbox input.id").keypress(function(e)
                {
                    key = e.which;
                    if (key === 13)
                    {
                        valueid = $("div#center-box div#empid-textbox input").val();

                        /*this is the only thing I changed*/
                        if ($("div#esd-names li[class*='" + valueid + "']") != null)
                        {
                            //DO SOMETHING;
                            $("div#esd-names li[class*='" + valueid + "']").css("background-color", "red");
                        }
                    }
                });
}

. , . , .

0

Put the number in the attribute reland check that$("div#esd-names li[rel=" + valueid + "]")

0
source

Source: https://habr.com/ru/post/1741143/


All Articles