我有一个带有 a 的代码link
,当单击我想做某事的链接时,但我不知道为什么单击不起作用,并且警报甚至不会触发
jQuery代码
$(document).ready(function(){
$("#editConcept").on('click','ecAddLink',function(){
$.getJSON("http://localhost/Mar7ba/Ontology/getAllConcepts/TRUE",function(data){
alert("William Roma");
var options = '';
options+="<option>Select Concept</option>";
for(var i=0;i<data.length;i++){
options += "<option>"+data[i]+"</option>";
}
$.getJSON("http://localhost/Mar7ba/Ontology/getAllRelations/TRUE",function(data){
var options2 = '';
options2+="<option>Select Concept</option>";
for(var i=0;i<data.length;i++){
options2 += "<option>"+data[i]+"</option>";
}
$("#editConcept ul li:last").before('\
<li>\n\
<p>\n\
<label>Concept</label>\n\
<select name="newConcepts[]">'+options+'</select>\n\
<span class="errorMessage"></span>\n\
</p>\n\
<p>\n\
<label>Relations</label>\n\
<select name="newRelations[]">'+options2+'</select>\n\
<span class="errorMessage"></span>\n\
<a href="#" class="removeA">delete</a>\n\
</p>\n\
</li>');
});
});
});
});
html代码
<div id="editConcept" class="container">
<form id="ecForm" method="POST" action="<?php echo URL; ?>Ontology/conceptEdit">
<ul>
<li>
<label>Select Concept</label>
<select class="ConceptSelector1"></select>
<span class="errorMessage"></span>
</li>
<li id="ecOldRelations">
<p>
<label>Old Relations</label>
</p>
</li>
<li id="ecNewRelations">
<label>New Relations</label>
<a href="#" class="smallLink" id="ecAddLink">add new relations</a>
</li>
<li>
<input type="submit" class="button1" value="save"/>
</li>
</ul>
</form>
</div>
the link has an id = ecAddLink