Is it possible to use a for loop in <select> in html? and how?

后端 未结 6 1521
不知归路
不知归路 2021-01-05 20:38

I am trying to use a for loop in html but i dont even know if this is possible. Is it? and if yes how? I dont want to use php. only html and javascript.

this is my

6条回答
  •  醉梦人生
    2021-01-05 20:54

    No you can't use a for loop in HTML. HTML is a markup language, you cannot use logical code. However you could use javascript to do your logic depending on what your objective is.

    Here is an example using jQuery, a popular javascript library:

    for(i=0; i<5; i++){
        $("select").append("");
    } 
    

    See example: http://jsfiddle.net/T4UXw/

提交回复
热议问题