$(".td").click(function() {
switch (elementNode.previousSibling.id)
{
case "location"
(".td").replaceWith('<input type="text" name="location"></input>');
break;
case "occ"
(".td").replaceWith('<input type="text" name="occ"></input>');
break;
case "hobby"
(".td").replaceWith('<input type="text" name="hobby"></input>');
break;
}
});
The above is the Javascript that I'm working with, and here is the HTML
<div class="tr"><div class="td" id="location">{L_LOCATION}:</div> <div class="td">{LOCATION}</div></div>
<div class="tr"><div class="td" id="occ">{L_OCCUPATION}:</div> <div class="td">{OCCUPATION}</div></div>
<div class="tr"><div class="td" id="hobby">{L_INTERESTS}:</div> <div class="td">{INTERESTS}</div></div>
What I'm wanting to do is when someone clicks on the ".td" div for it to turn into an input field. The reason that I think I need to use switch is there is a lot of conditions that need to be met (as you can see within the code) and that would be too many if and else statements. So I'm not sure if I'm doing this right, as I've just started programming (complete beginner here, so pardon me if there are a ton of errors) The content you see within the HTML tags are template variables in case you're wondering.