संपादित करें: अंतिम समाधान के लिए https://jsfiddle.net/DTcHh/40740/ पर जाएं!मैं एक फ़ंक्शन कैसे बना सकता हूं जो प्रतिलिपि बनाता है और अपने स्वयं के div को सम्मिलित करता है?
मेरे पास "जोड़ें प्रश्न" (बूटस्ट्रैप) रेडियो बटन वाला एक div है। मेरा इरादा यह है कि div जिसमें बटन रखा गया है की नकल की और नीचे रखा जाना चाहिए जब उल्लेख बटन क्लिक किया जाता है:
मुझे लगता है कि कैसे करते हैं? जब मैं बटन पर क्लिक करता हूं तो कुछ भी नहीं होता है।
HTML:
<div id="singleQuestionModule">
<div class="question-wrapper">
<form class="form-group">
<div class="d-flex justify-content-center">
<fieldset class="form-group row">
<legend class="col-form-legend col-sm-10"></legend>
<div class="form-group row">
<div class="input-group input-group">
<label id="wQuestionLabel" class="form-control-label" style="width: 540px;" for="wQuestion">Question:</label>
</div>
</div>
<div class="form-group row">
<div class="input-group input-group">
<input type="text" class="form-control" aria-label="" id="wQuestion" style="width: 540px;">
</div>
</div>
<div class="form-group row">
<div class="input-group input-group">
<label id="questionOptions" class="form-control-label" style="width: 540px;"
for="wQuestion">Enter
avaible options:</label>
</div>
</div>
<div class="form-group row">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-success">
<input type="radio" name="options" id="radioAddQuestion"
onclick="addQuestionModule('singleQuestionModule')"
autocomplete="off">Add Question</label>
<label class="btn btn-success">
<input type="radio" name="options" id="radioSaveTest" value="saveTest()"
autocomplete="off">Save Test </label>
</div>
</div>
</fieldset>
</div>
</form>
</div>
</div>
jQuery
$("#radioAddQuestion").click(function() {
var html = $("#" + singleQuestionModule).html();
$(html).insertAfter("#" + singleQuestionModule);
});
This is a working example (मेरी कोड नहीं) है कि मैं पुन: पेश करने की कोशिश की।
आपकी समस्या यह है कि आप सामान्य बी के बजाय रेडियो इनपुट का उपयोग करते हैं uttons। रेडियो इनपुट '.click()' फ़ंक्शन – DestinatioN
का समर्थन नहीं करते हैं आप रेडियो के रूप में बटन का उपयोग क्यों कर रहे हैं? बस '
शामिल नहीं किया है, मैं 100% सुनिश्चित नहीं हूं कि आप क्या करना चाहते हैं लेकिन विचार कस्टम परीक्षण बनाना है आपको प्रश्न जोड़ने की आवश्यकता है और अंत में परीक्षण को "सेव" करें, है ना? आपको अपने 2 बटन div से बाहर रखना चाहिए और केवल प्रश्न जोड़ना चाहिए, यदि प्रत्येक ब्लॉक में "प्रश्न जोड़ें" और "परीक्षण सहेजें" बटन है तो यह अजीब है, नहीं? –