I have a challenge where I need to extract an ID from an HTML element and then replace part of the extracted word. For instance:
HTML
<input type="checkbox" id="facebookCheckbox"></div>
JavaScript
var x = document.getElementById("facebookCheckbox");
var name = x.id;
name.replace("Checkbox","");
The method above doesn't work as expected because the word being replaced must be standalone. Is there an alternative approach to achieve this?
I prefer using plain Javascript without involving jQuery.
Appreciate any guidance!