Jump to content

How to add icon in the textbox


Recommended Posts

Hai... 

iam newbie in jquery sintaks

i try to add icon in the  textbox on login.. class textbox is below class form-group row

my script is

var header = '<span class="form-group row"><i class="fa fa-user"></i></span>';
$('[class="input-group-addon"]').prepend(header);

but the result is nothing

can you help me

Thank you

 

 

Untitled.png

Link to post
Share on other sites

I don't see any elements in your code with a class "input-group-addon". You need to add that element to your HTML for this code to work. Either that, or use a different class name to select the element.

You should use the class selector instead of the attribute selector, otherwise it will only select elements that have exactly that class name and nothing more. The class selector is the same as in CSS:

$('.input-group-addon').prepend(header); 

jQuery is not necessary for this. It can be done with plain Javascript:

var header = '<span class="form-group row"><i class="fa fa-user"></i></span>';
var element = document.querySelector(".input-group-addon");
element.innerHTML = header + element.innerHTML;

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...