I created a button, so when I click on it, a random map appears. On a random card (s) there is an "x". I cannot put an "x" in the upper right corner, and I do not know why it does not work.
I want to create a function so that clicking on the "x" random card is deleted.
Here is my HTML:
<button class="plus">
<div class="item">
<p> + </p>
</div>
</button>
<div id="newCardHolder">
</div>
<div id="cardPrototype" class="card" style="display:none;">
<p class="delete">x</p>
<span> Title </span>
<form name="theform" style="display:none;">
<input class="input-feld" type="text">
<br>
<input class="input-feld " type="text">
<br>
<input class="speichern"type="button" onClick="new Person()" value="Speichern">
<input class="abbrechen"type="button" onClick="new Person()" value="Abbrechen">
</form>
</div>
My CSS:
.input-feld {
font-family: TheSans Swisscom;
margin:3px;
}
.card {
width:300px;
margin-right:5px;
margin-left:5px;
margin-bottom:10px;
float: left;
padding:10px;
background-color: #BBBBBB;
border: 1px solid #ccc;
border-radius:10px;
}
.delete {
font-family:'TheSans Swisscom';
right:0;
top:0;
}
.speichern{
font-family:'TheSans Swisscom';
}
.abbrechen{
font-family:"TheSans Swisscom";
background-color: greenyellow;
}
And my jQuery:
$(document).ready(function () {
$("button.plus").on("click", function () {
var newCard = $('#cardPrototype').clone(true);
$(newCard).css('display', 'block').removeAttr('id');
$('#newCardHolder').append(newCard);
});
$('body').on('click', '.card', function () {
$(this).find('form').show();
$(this).find('span').remove();
});
});
source
share