class (Object) vs id

During the web development i encountered with many problems and resolved it but these problems gave me a thought which i want to share and would like to know your view. Which One is efficient `Class Or ID` : Both has own specification but i think Class is more convenient over ID (if you are dealing with thousands of IDs.) I know Id is quite efficient for DOM Traversing but what if you have hundreds of elements with IDs, How do you manage ? Using CLASS : One class can be derived by many elements and the individual elements can be dealt by using `"this" object`. I am curious to know your view OR how do you handle the project/projects when you have many-many elements with ID or Class name
function click(obj){ alert(obj.classname + "We can access any individual element by using Object"); }
but in case of ID, we go through each ID

以上就是class (Object) vs id的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准