Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
cursor focus on particular dropdownlist using id in javascript

What I have tried:

if (fent == "PAINTED") {
var fpaint = $('#paintmul').val();
if (fpaint == null) {
document.getElementById('paine').style.display = 'block';
//$("#myid").focus();
$('paintmul').focus();
}

}
Posted
Updated 9-May-16 23:17pm

1 solution

Hello ,
To focus the control using jquery try this
$("#id").focus();

Thanks
 
Share this answer
 
Comments
Nethaji chennai 10-May-16 5:31am    
its not working for me i want in javascript can any one help me
Animesh Datta 10-May-16 5:37am    
you are getting the value by query , then what the reason to set the focus by javascript ...
to set the focus by javascript use
document.getElementById("id").focus();
Nethaji chennai 10-May-16 5:51am    
this also is no working . the id id multiple select list box. other will work like textbox, drop down list but list box is not work can you help me
Sergey Alexandrovich Kryukov 10-May-16 9:24am    
Probably it's working, but you cannot realize it, because you probably don't know what is "focus". I could suspect it by your question. There is no such thing as "cursor focus". "Focus" always means keyboard focus. You may confuse focusing with selection, or something else.

Also, you may use wrong selector. I could guess by your code sample when you use different selectors: 'paintmul' and '#paintmul'. At least one of them is wrong. Do you really have it in the attribute "id"?

—SA
Sergey Alexandrovich Kryukov 10-May-16 9:29am    
I up-voted the answer with my 4. You are right, but you did not explain about the attribute id and other things. From the formulation of the question, it's more or less apparent that the inquirer needs some explanations and may not know about the role of "id" and notion of "focus".
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900