কম্পিউটার টিউটোরিয়াল

HTML DOM Select selectedIndex প্রোপার্টি


HTML DOM select selectedIndex প্রোপার্টি HTML ডকুমেন্টে ড্রপ-ডাউন লিস্টের সিলেক্ট করা অপশনের ইনডেক্স রিটার্ন ও মডিফাই করে।

সিনট্যাক্স

নিচে সিনট্যাক্স দেওয়া হলো:

  • selectedIndex রিটার্ন করা

object.selectedIndex
  • selectedIndex মডিফাই করা

object.selectedIndex = "number"

উদাহরণ

HTML DOM select selectedIndex প্রোপার্টির উদাহরণ:

<!DOCTYPE html> <html> <head> <style>    html{       height:100%;    }    body{       text-align:center;       color:#fff;       background: radial-gradient( circle farthest-corner at 23.1% 64.6%, rgba(129,125,254,1) 0%, rgba(111,167,254,1) 90% ) no-repeat;       height:100%;    }    p{       font-weight:700;       font-size:1.1rem;    }    .drop-down{       display:block;       width:35%;       border:2px solid #fff;       font-weight:bold;       padding:2px;       margin:1rem auto;       outline:none;    }    .btn{       background:orange;       border:none;       height:2rem;       border-radius:2px;       width:35%;       margin:2rem auto;       display:block;       color:#fff;       font-weight:bold;       outline:none;       cursor:pointer;    }    .show{       font-size:1.5rem;       font-weight:bold;    } </style> </head> <body> <h1>DOM Select selectedIndex property Demo</h1> <p>Hi, Select your favourite subject:</p> <select class='drop-down' name="Drop Down List"> <option>Physics</option> <option>Maths</option> <option>Chemistry</option> <option>English</option> <option>Economics</option> <option>Hindi</option> <option>Biology</option> </select> <button type="button" onclick="set()" class="btn">Set selectedIndex</button> <div class="show"></div> <script>    function set() {       var dropDown = document.querySelector(".drop-down");       document.querySelector(".show").innerHTML="put selectedIndex = '3'";       dropDown.selectedIndex="3";    } </script> </body> </html>

আউটপুট

এটি নিচের আউটপুট প্রডিউস করবে:

HTML DOM Select selectedIndex প্রোপার্টি

"Set selectedIndex" বাটনে ক্লিক করলে ড্রপ-ডাউন লিস্টে selectedIndex='3' সেট হবে।

HTML DOM Select selectedIndex প্রোপার্টি

  1. HTML DOM parentElement প্রোপার্টি

  2. HTML DOM Option value প্রোপার্টি

  3. HTML DOM Option label প্রোপার্টি

  4. HTML DOM Option defaultSelected প্রোপার্টি