Assign jquery list value to text button

Assign the jQuery Variable (caintains Mobile number and cantact name) to the text button. I have a list in which list items are repeated in jsp using jquery and math.random, getting a random item (containing mobile_num and name) when assigning a value to the text field, it gets only one value ... here, how the code looks like .. .

<ul><s:iterator value="CantactList"> <li> <s:property value="name"/>
<s:property value="Mobile Number"/><li></s:iterator></ul>

and in jQuery ...

$form = $("<form action="+"xyz"+"></form>");
$form.append('<input type="text" value='+item+' name="Cantact"/>');

if I use lable or alert (item) works fine .... after executing this code I check the input field. where the code is as follows.

<input type="text" 9333333="" value="Jhon" name="Cantact"/>

can't understand why this is happening ... advice ... ??

+4
source share
1 answer

$form = $("<form action="+"xyz"+"></form>");  
$form.append('<input type="text" value='+item+' name="Cantact"/>');

$form = $('<form action="xyz"></form>'); // not so important
$form.append('<input type="text" value="'+item+'" name="Cantact"/>'); //this is more important
+3

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


All Articles