JQuery/Javascript functions with dynamics id
up vote
0
down vote
favorite
I'm in this situation, where I have a div and a button:
<div style="display:none" class="partita" onkeypress="editPartita(e,???????)" >
...
</div>
<button id="plusPartite"></button>
Onclick of this button there is another function:
function ShowNewPartite(i)
var a = document.getElementsByClassName("partita");
a[0].style.display = 'unset';
var newI = parseInt(i) + 1;
var newId = "partita" + newI ;
a[0].setAttribute("id", newId);
that assign an dinamic id on div and I want that if the user keypress on the div "partita",there is another function that is:
editPartita(e,id)
if(e.which == 13)
...
that save on DB the elements.
How I call back the id that is created in a ShowNewPartite(i) for a new div "partita",in the function editPartita(e,??) ?
Thankyou
javascript html
add a comment |
up vote
0
down vote
favorite
I'm in this situation, where I have a div and a button:
<div style="display:none" class="partita" onkeypress="editPartita(e,???????)" >
...
</div>
<button id="plusPartite"></button>
Onclick of this button there is another function:
function ShowNewPartite(i)
var a = document.getElementsByClassName("partita");
a[0].style.display = 'unset';
var newI = parseInt(i) + 1;
var newId = "partita" + newI ;
a[0].setAttribute("id", newId);
that assign an dinamic id on div and I want that if the user keypress on the div "partita",there is another function that is:
editPartita(e,id)
if(e.which == 13)
...
that save on DB the elements.
How I call back the id that is created in a ShowNewPartite(i) for a new div "partita",in the function editPartita(e,??) ?
Thankyou
javascript html
3
Don't dynamically change anid
. You can use data-attributes developer.mozilla.org/en-US/docs/Learn/HTML/Howto/… instead. Don't ever mess with an element'sid
once you set it and don't ever have two elements that share an id in the same scope of an application.
– zfrisch
Nov 9 at 20:20
6
If you create snippets, make sure it makes sense to run them.
– connexo
Nov 9 at 20:26
Setup theonkeypress
handler from JavaScript usingElement.prototype.addEventListener
– Aluan Haddad
Nov 9 at 20:31
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm in this situation, where I have a div and a button:
<div style="display:none" class="partita" onkeypress="editPartita(e,???????)" >
...
</div>
<button id="plusPartite"></button>
Onclick of this button there is another function:
function ShowNewPartite(i)
var a = document.getElementsByClassName("partita");
a[0].style.display = 'unset';
var newI = parseInt(i) + 1;
var newId = "partita" + newI ;
a[0].setAttribute("id", newId);
that assign an dinamic id on div and I want that if the user keypress on the div "partita",there is another function that is:
editPartita(e,id)
if(e.which == 13)
...
that save on DB the elements.
How I call back the id that is created in a ShowNewPartite(i) for a new div "partita",in the function editPartita(e,??) ?
Thankyou
javascript html
I'm in this situation, where I have a div and a button:
<div style="display:none" class="partita" onkeypress="editPartita(e,???????)" >
...
</div>
<button id="plusPartite"></button>
Onclick of this button there is another function:
function ShowNewPartite(i)
var a = document.getElementsByClassName("partita");
a[0].style.display = 'unset';
var newI = parseInt(i) + 1;
var newId = "partita" + newI ;
a[0].setAttribute("id", newId);
that assign an dinamic id on div and I want that if the user keypress on the div "partita",there is another function that is:
editPartita(e,id)
if(e.which == 13)
...
that save on DB the elements.
How I call back the id that is created in a ShowNewPartite(i) for a new div "partita",in the function editPartita(e,??) ?
Thankyou
<div style="display:none" class="partita" onkeypress="editPartita(e,???????)" >
...
</div>
<button id="plusPartite"></button>
<div style="display:none" class="partita" onkeypress="editPartita(e,???????)" >
...
</div>
<button id="plusPartite"></button>
function ShowNewPartite(i)
var a = document.getElementsByClassName("partita");
a[0].style.display = 'unset';
var newI = parseInt(i) + 1;
var newId = "partita" + newI ;
a[0].setAttribute("id", newId);
function ShowNewPartite(i)
var a = document.getElementsByClassName("partita");
a[0].style.display = 'unset';
var newI = parseInt(i) + 1;
var newId = "partita" + newI ;
a[0].setAttribute("id", newId);
editPartita(e,id)
if(e.which == 13)
...
editPartita(e,id)
if(e.which == 13)
...
javascript html
javascript html
edited Nov 9 at 20:52
Barmar
413k34237339
413k34237339
asked Nov 9 at 20:12
user10276822
43
43
3
Don't dynamically change anid
. You can use data-attributes developer.mozilla.org/en-US/docs/Learn/HTML/Howto/… instead. Don't ever mess with an element'sid
once you set it and don't ever have two elements that share an id in the same scope of an application.
– zfrisch
Nov 9 at 20:20
6
If you create snippets, make sure it makes sense to run them.
– connexo
Nov 9 at 20:26
Setup theonkeypress
handler from JavaScript usingElement.prototype.addEventListener
– Aluan Haddad
Nov 9 at 20:31
add a comment |
3
Don't dynamically change anid
. You can use data-attributes developer.mozilla.org/en-US/docs/Learn/HTML/Howto/… instead. Don't ever mess with an element'sid
once you set it and don't ever have two elements that share an id in the same scope of an application.
– zfrisch
Nov 9 at 20:20
6
If you create snippets, make sure it makes sense to run them.
– connexo
Nov 9 at 20:26
Setup theonkeypress
handler from JavaScript usingElement.prototype.addEventListener
– Aluan Haddad
Nov 9 at 20:31
3
3
Don't dynamically change an
id
. You can use data-attributes developer.mozilla.org/en-US/docs/Learn/HTML/Howto/… instead. Don't ever mess with an element's id
once you set it and don't ever have two elements that share an id in the same scope of an application.– zfrisch
Nov 9 at 20:20
Don't dynamically change an
id
. You can use data-attributes developer.mozilla.org/en-US/docs/Learn/HTML/Howto/… instead. Don't ever mess with an element's id
once you set it and don't ever have two elements that share an id in the same scope of an application.– zfrisch
Nov 9 at 20:20
6
6
If you create snippets, make sure it makes sense to run them.
– connexo
Nov 9 at 20:26
If you create snippets, make sure it makes sense to run them.
– connexo
Nov 9 at 20:26
Setup the
onkeypress
handler from JavaScript using Element.prototype.addEventListener
– Aluan Haddad
Nov 9 at 20:31
Setup the
onkeypress
handler from JavaScript using Element.prototype.addEventListener
– Aluan Haddad
Nov 9 at 20:31
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232699%2fjquery-javascript-functions-with-dynamics-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Don't dynamically change an
id
. You can use data-attributes developer.mozilla.org/en-US/docs/Learn/HTML/Howto/… instead. Don't ever mess with an element'sid
once you set it and don't ever have two elements that share an id in the same scope of an application.– zfrisch
Nov 9 at 20:20
6
If you create snippets, make sure it makes sense to run them.
– connexo
Nov 9 at 20:26
Setup the
onkeypress
handler from JavaScript usingElement.prototype.addEventListener
– Aluan Haddad
Nov 9 at 20:31