Hello there, I'm new to Jquery, and I've been seraching the site for a
while and couldn't get an answer to my problem. Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Jquery add ids</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">

        $(document).ready(function (){

                        var obj = $('.boxy');
                        var repeatIdName = 'myBoxNum';
                        i = 1, 2, 3, 4, 5, 6, 7, 8; //Count

                        $('.boxy').attr('id', (repeatIdName + i));

        });
</script>
<style type="text/css">

        body {margin:0; padding:0;}
                .boxy {margin:30px; padding:10px; border:1px dotted #CCC; width:
400px; background:#EEE;}

</style>
</head>

<body>

        <div class="boxy"><strong>Contenido</strong></div>
        <div class="boxy"><strong>Contenido</strong></div>
    <div class="boxy"><strong>Contenido</strong></div>
    <div class="boxy"><strong>Contenido</strong></div>

</body>
</html>


I want to add an unique id to all boxy elements. I already tried with
for {i =0; i <=10... stuff also, I'm quite lost.

I appreciate your help.
Regards,

Ignacio

Reply via email to