0

i wanted the XML attributes values which comes on page using Jquery should get underline at specific Character.

can any one please help me on this.?

Thank you in advance.

$(menuGroup).append('<a href="#" id="'+menuGroupName+'" onclick="SearchByDE(this.id)" title="'+menuTooltipNote+'" accesskey="'+menuAccessKey+'" class="hasSubMenu left_nav_menu">'+'<p style="padding-top:6px;">'+menuGroupName+'</p>'+'</a>');
Anujith
  • 9,370
  • 6
  • 33
  • 48
Vijay
  • 1,026
  • 3
  • 11
  • 28
  • have seen problem solution here but how can make sure that in my query http://stackoverflow.com/questions/6444183/style-a-certain-character-in-a-string – Vijay Mar 27 '13 at 06:23
  • Your question isn't very clear. What is your XML data and how does it relate to the above code? What jQuery UI widget are you using/ – Barmar Mar 27 '13 at 06:37
  • XML stored menu items will come as Menu. For Menu, Submenu items i have mapped shortcuts. i want to show the Shortcut by underlining the char which part of string. – Vijay Mar 27 '13 at 10:13
  • XML store data has to comes as menu. i have mapped keys and i want to underline a char which is part of the string. Eg: assume Vijay is the string, how can put a underline for V only. pls advise... – Vijay Mar 27 '13 at 10:19

1 Answers1

0

CSS:

.accesskey { text-decoration: underline; }

JS:

var accessIndex = menuGroupName.indexOf(menuAccessKey);
menuID = menuGroupName;
if (accessIndex !== null) {
    menuGroupName = menuGroupName.substr(0, accessIndex-1) + '<span class="accesskey">' +
                    menuAccessKey + '</span>' + menuGroupName.substr(accessIndex+1);
}
$(menuGroup).append('<a href="#" id="'+menuID+'" onclick="SearchByDE(this.id)" title="'+menuTooltipNote+'" accesskey="'+menuAccessKey+'" class="hasSubMenu left_nav_menu">'+'<p style="padding-top:6px;">'+menuGroupName+'</p>'+'</a>');

I still don't see any dependency on XML in this. Maybe the menu data comes from XML, but I don't see how that matters for the formatting.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • still am not able, as such when i try this in my page displaying entire html component(anchor tag) with details.. am not sure why.. – Vijay Mar 29 '13 at 11:07
  • Anchor text is normally underlined, did you change the CSS to override this so only the access key will be underlined? – Barmar Mar 29 '13 at 14:07
  • yes, i have put that also in jsp page inside . No impact seen. :( – Vijay Mar 30 '13 at 10:10
  • Try it now. I didn't notice that you were using `menuGroupName` as the ID, I added a new variable for that. – Barmar Mar 30 '13 at 14:09
  • i have solved this, `var part1=menuGroupName.substr(0,indexStart);` `var part2 = menuGroupName.charAt(indexStart);` `part2 = ''+part2+'';` `var part3 = menuGroupName.substr(indexEnd);` `var menuGroupNameChanged = part1+part2+part3;` the final value can be added and resultant text comes up with underline. – Vijay Apr 11 '13 at 13:21
  • I think that should be the same. `` is frowned upon these days, CSS classes are preferred. – Barmar Apr 11 '13 at 13:33
  • may be but when i try using Css classes based code, it did not work. Anyways, Thanks a lot. – Vijay Apr 13 '13 at 11:57