2016-09-25 17 views
-1

正如你所有人都看到一行,並且當你點擊x時colum有框和x,那麼該行被刪除。添加紅十字以從行中刪除框

如何添加這個

enter image description here

enter image description here

我在其他線程讀取

window.onload = function(){ 
    document.getElementById('close').onclick = function(){ 
     this.parentNode.parentNode.parentNode 
     .removeChild(this.parentNode.parentNode); 
     return false; 
    }; 
}; 
Css for close button 

#close { 
    float:right; 
    display:inline-block; 
    padding:2px 5px; 
    background:#ccc; 
} 

You may add a hover effect like 

#close:hover { 
    float:right; 
    display:inline-block; 
    padding:2px 5px; 
    background:#ccc; 
    color:#fff; 
} 

這是我的PHP代碼

<?php 


    $post = get_post(get_the_ID()); 
    $auth = $post->post_author; 

    $lnk = $privurl_m . 'priv_act=send&pid='.get_the_ID().'&uid='.$auth; 

    $author = get_the_author(); 
    echo '<li>'; 
    echo '<span>'.sprintf(__('<a href="%s">%s</a> requested gig',"PricerrTheme"),$lnk,"<font color=\'red'>" . $author ."</font>").':</span><br/>'; 
    echo "Title: ".get_the_title(); echo'<br/> <span>'; 
    _e("Posted in","PricerrTheme");?> <?php echo get_the_term_list(get_the_ID(), 'request_cat', '', ', ', ''); 
    echo '</span>'; 
    echo '<input class="btnnn-class" type="btnnn-class" onClick="window.location.href=\'' . $lnk . '\'" value="Contact Buyer">' ; 
    echo '</li>'; 


?>  

如何將代碼添加到此列表中,以便在每列上添加x,然後如果它消失,我可以按它並選擇它。

回答

1

您不能有重複id s。所以你需要先改變你的CSS。

.close { 
    float:right; 
    display:inline-block; 
    padding:2px 5px; 
    background:#ccc; 
} 

.close:hover { 
    float:right; 
    display:inline-block; 
    padding:2px 5px; 
    background:#ccc; 
    color:#fff; 
} 

然後在PHP代碼,內環路,添加關閉按鈕:

echo '<input class="btnnn-class" type="btnnn-class" onClick="window.location.href=\'' . $lnk . '\'" value="Contact Buyer"> <a class="close" href="#">&times;</a>' ; 
+0

其添加的CRO公司,當我點擊它,它不刪除它怎麼過這個代碼,我發現作品 x但它刪除了所有的框 –

+0

請幫助你的代碼不刪除它?我需要做什麼 –