0

How to show different content for different buttons using jquery

<div id="output"></div>  
<div id="overlay" class="web_dialog_overlay"></div>
<div id="dialog" class="web_dialog">
<table style="width: 100%; border: 0px;" cellpadding="3" cellspacing="0">
  <tr>
     <td class="web_dialog_title">Email this Article</td>
     <td class="web_dialog_title align_right">
        <a href="#" id="btnClose">Close</a>
     </td>
  </tr>

  <tr>
<td colspan="2" style="text-align: center;">

content
</td></tr></table>

$(document).ready(function () { 
    $("#btnShowSimple").click(function (e) {
        ShowDialog(false);  
        e.preventDefault(); 
    });
    $("#btnShowShare").click(function (e) {
        ShowDialog(false); 
        e.preventDefault(); 
    }); 
    $("#btnClose").click(function (e) {
        HideDialog(); 
        e.preventDefault(); 
    }); 
    $(document).keyup(function(e) {
        if (e.keyCode == 27) { 
            HideDialog(); 
        }
    });
 }); 
4

1 に答える 1

0

私はそのようcontentdiv要素に入れます: <div id="myContent">content</div> 次にスクリプトで: $("#myContent").html("New content"); 各関数で。このようなもの:

$(document).ready(function () { 
    $("#btnShowSimple").click(function (e) {
        ShowDialog(false);  
        $("#myContent").html("Simple content");
        e.preventDefault(); 
    });
    $("#btnShowShare").click(function (e) {
        ShowDialog(false); 
        $("#myContent").html("Share content");
        e.preventDefault(); 
    }); 
    $("#btnClose").click(function (e) {
        HideDialog(); 
        e.preventDefault(); 
    }); 
    $(document).keyup(function(e) {
        if (e.keyCode == 27) { 
            HideDialog(); 
        }
    });  });

編集

コメントでリンクしたコードで行うことは次のとおりです(関連部分):

  $("#btnShowSimple").click(function (e)
  {
     $("#dialog").html("Simple");
     ShowDialog(false);
     e.preventDefault();
  });

  $("#btnShowModal").click(function (e)
  {
     $("#dialog").html("Modal");
     ShowDialog(true);
     e.preventDefault();
  });
于 2012-05-25T05:51:18.410 に答える