javascript - Finding a specific html element in a htmlCollection array using jquery -
i hope worded title correctly.
basically working in sharepoint environment. on every page of site have sidebar menu quicklinks various other pages.
in sidbar menu mostly, if not entirely, generated sharepoint each menu item in list given class 'menu-item-text'.
now there specific menu item want to, using javascript, append text existing text. counter specifically.
so have this..
- menuitem1
- menuitem2
- menuitem3
- menuitem4
- menuitem5
and want calculation on page load , display numeric results of calculation menuitem3, such as..
- menuitem1
- menuitem2
- menuitem3 (5)
- menuitem4
- menuitem5
so assume way via javascript. , easy if target directly id, have generic class name - <span class="menu-item-text">menuitem3</span>
if use document.getelementsbyclassname('menu-item-text')
, given 'htmlcollection[389]'
how can find 'menuitem3' item in array? assume can idenitfy 'innerhtml' of 'menu-item-text' object equal 'menuitem3'.
but unsure how. :)
thanks!
edit: here html looks on page side bar. there lot it...
well either class name or html text should permanent fixed html. if li text fixed 'menuitem3' , having class 'menu-item-text'
then can in way.
var element = $('.menu-item-text:contains("menuitem3")')
otherwise should allocated id each element based on requirement.
here plunker
Comments
Post a Comment