#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Posts
    277
    Rep Power
    0

    Move element in to td


    Code:
    <table>
      <thead>
        <tr>
    
          <td>Customer :</td>
          <td>Contact :</td>
          <td>City :</td>
          <td>Adres :</td>
          <td>image :</td>
    
        </tr>
        </thead>
        <tbody>
        <tr id="tr1">
          <td>ROMEY</td>
          <td>Alejandra Camino</td>
          <td>Madrid</td>
          <td>Gran Va, 1</td>
          <td>&nbsp;</td>
    
        </tr>
        <tr id="tr2">
    
          <td>MORGK</td>
          <td>Alexander Feuer</td>
          <td>Leipzig</td>
          <td>Heerstr. 22</td>
          <td>&nbsp;</td>
    
        </tr>
        <tr id="tr3">
    
          <td>ANATR</td>
          <td>Ana Trujillo</td>
          <td>Mxico D.F.</td>
          <td>Avda. de la Constitucin 2222</td>
          <td>&nbsp;</td>
        </tr>
    
    
       
      </tbody>
    </table>
    Code:
    <style>
    .d1{
    	border:solid 0px #09C;
    	height:30px;
    	width:200px;
    	display:none;
    	}
    </style>
    <script language="javascript">
    	$(document).ready(function(){
            $('td').bind('dblclick',function(){
    				var dv = $(this).text();
    				$(this).replaceWith( $(".d1") );
    			});		
        });
    
    </script>
    <div id="son" class="d1">
    	<input type="text"  class="t1" id="t1"/>
        <input type="button"  class="b1" value="OK"/>
        <input type="button"  class="i1"  value="iptal"/>
    </div>

    when i click any td i wanna move <div> is called d1 into td i clicked. i tried like above but it isnt
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    50
    1. This is not related to your problem, but FYI, the "language" attribute on the script tag is deprecated. Instead, you should be using type="text/javascript".

    2. Just checking, you did include jquery, right?

    3. This is also, not the problem, but .... I'm thinking you want to use the selector #son, not .d1. You may have only one #son, but you could have many .d1 which would get very confusing.

    4. You're very close.

    In this line:
    Code:
    $(this).replaceWith( $(".d1") );
    you are asking this to be replaced with an object. But what you want is the content of the object.

    Try:
    Code:
    $(this).replaceWith( $(".d1").html() );
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Posts
    277
    Rep Power
    0
    Originally Posted by EEsterling
    1. This is not related to your problem, but FYI, the "language" attribute on the script tag is deprecated. Instead, you should be using type="text/javascript".

    2. Just checking, you did include jquery, right?

    3. This is also, not the problem, but .... I'm thinking you want to use the selector #son, not .d1. You may have only one #son, but you could have many .d1 which would get very confusing.

    4. You're very close.

    In this line:
    Code:
    $(this).replaceWith( $(".d1") );
    you are asking this to be replaced with an object. But what you want is the content of the object.

    Try:
    Code:
    $(this).replaceWith( $(".d1").html() );

    thanx

IMN logo majestic logo threadwatch logo seochat tools logo