0

I dynamically add textbox using jquery i want to fill each of them with same array value but every of them have different id

...

enter image description here

http://uupload.ir/files/owv5_1.jpg result i want for each textbox: http://uupload.ir/files/frwt_2.jpg

1
  • how about demo or code ?you don't have one Commented Feb 3, 2018 at 8:36

2 Answers 2

1

try this:

$('parentNodeIdOrClassName input').each(function(){
    $(this).val('your value');
})
Sign up to request clarification or add additional context in comments.

2 Comments

i have many input on that page I want something more specific
@mostafaasadollahy you just give us a picture.we need code,how about you add a id to the input parentNode
0

Try This.

<!DOCTYPE html><html>
<head>
    <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script type="text/javascript">
        var index = 1;
        $(document).ready(function(){
            $('.addrow').click(function(e){
                var html = '';
                html += '\
                <tr>\
                    <td><input id="id'+ index++ +'" value="value1" type="text" name="filed1[]"></td>\
                    <td><input id="id'+ index++ +'" value="value2" type="text" name="filed2[]"></td>\
                    <td><input id="id'+ index++ +'" value="+" type="button" name="plus" ></td>\
                </tr>\
                ';
                $('table > tbody').append(html);
                return false;
            });
        });
    </script>
    <style type="text/css">
        table{
            width: 100%;
        }
        table td{
            border:1px solid #000;
        }
    </style>
</head>
<body>
    <button class="addrow">+</button>
    <table>
        <thead>
            <tr>
                <th>Column1</th>
                <th>Column2</th>
                <th>#</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</body>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.