4

Here is my jquery and div i want to hide tblMain and make tblmainalt visible

$("btnUpdate").click(function() {
  alert("button");
  $("tblMain").hide();
  $("tblMainAlt").show();
});
<div id="tblMainAlt" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;">
<div id="tblMain" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;">

2
  • your selectors are wrong - where are the dots (for classes) or hashes (for ids)? Commented Mar 27, 2017 at 12:07
  • Use like this $("#btnUpdate"), $("#tblMain").hide(); $("#tblMainAlt").show(); Commented Mar 27, 2017 at 13:15

2 Answers 2

6

This is because you have used wrong selector. Either you have to use ID or CLASS selector. As seeing you HTML you please replace your jQuery with mine and it will worked.

$("#btnUpdate").click(function() {
  alert("button"); // Remove this line if it worked
  $("#tblMain").hide();
  $("#tblMainAlt").show();
});
Sign up to request clarification or add additional context in comments.

Comments

0

set display: none in style in tblMainAlt because loaded first time a page so hide a div.

i have add sample code so you can try it.

JQuery:-

$("#btnUpdate").click(function () {
                alert("button");
                $("#tblMain").hide();
                $("#tblMainAlt").show();
            });

 <div id="tblMainAlt" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;display: none;">

<div id="tblMain" class="tableSpaced" style="width:auto;height:100%;margin-left:25px;">

10 Comments

y shld i chng button id?
tblMain and tblMainAlt not a tag this is a id so add "#" on below(ID Name) for example "#tblMain" and "#tblMainAlt".
Any reason for negative voting?
can anyone tell me how to access div id into action in controller?
why access in controller?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.