ディスプレイを使用して、複数のdivカードを並べて表示します:インラインブロックです。カードをクリックすると、ボタン以下 div。divの下にボタンを追加する方法onclick
jqueryのafter()関数を使用していますが、divの右にボタンを追加しています。
どうすればいいですか?
PS:私は追加機能を使用しようとしましたが、divを再度クリックするとボタンを削除する別の機能があるため、ボタンをクリックするとdivのようになりますdivをクリックしてボタンが削除されているため、機能しません。
ありがとうございました!
が回答をいただき、誠にありがとうござい
編集... ...
は申し訳ありませんが、コードを示していないため、ここにある:
<div class = "classOfDiv">
here goes some product characteristics
</div>
$('.classOfDiv').click(
function() {
//gets the border because I need it to see if I'm clicking for the first time or second time.
var border = $(this).css("border");
//checks the border
if (border == "0px none rgb(51, 51, 51)") {
//change the border style to say that the div has been clicked
$(this).css("border", "3px solid blue");
//add the button
$(this).after("<button name = 'btnDetalhes' class = 'btn btn-primary'>Detalhes</button>");
} else {
//remove the border (now the div is diselected)
$(this).css("border", "0px none rgb(51, 51, 51)");
//remove the button
$(this).next("[name='btnDetalhes']").remove();
}
}
);
どこにあなたのコードはありますか? –
コードを投稿できますか? htmlに挿入するのではなく、ボタンを隠す/表示することについて考えるべきです。 – Shnibble
別の要素を配置しても、その要素が他の要素の下に表示されるわけではありません。これはCSSのためのものです... – yezzz