vendredi 7 juillet 2017

Creating input text field on marked checkbox in JQuery

I was asked to do something particular, and after trying I eventually found this site http://ift.tt/2uxBhHJ from which I'm using the JQuery. I however don't have any knowledge of it so I only understand in parts. What I'm trying to do is upon marking a checkbox an input type="text" appears below it, so if I check 3 results, input type="text"creates 3 fields, etc, and if I uncheck a checkbox, the camp gets deleted.

I've tried to do it by adding

$("div bb")
{
$('<input type="text" id="textbox" style="width:170px;"/><span> CHF <span>');
            }

after $(".hida").hide();but as I have no knowledge of JQuery it obviously didn't work and I don't really know what now. Also before that input, is it possible to add some sort of variable that is "attached" to the input so I can specificy what that input is for? Like if I check "Mercedes" in the checkbox, the input type="text" is created and above it the name "Mercedes" then if I check "BMW" it makes another input type="text" with BMW written above it?

Also wruting the code like this $("div bb") { for some reason disabled the $. Not sure why.




Aucun commentaire:

Enregistrer un commentaire