Answer the question
In order to leave comments, you need to log in
How to add that block?
I'm trying to make it so that by clicking on a link, a certain block from a separate .html file is added to its parent. Everything seems to work out, but not a separate block is added, but completely everything that is.
The code is like this:
$('.list-item a').click(function (){
event.preventDefault();
var link = $(this);
var here = link.parent();
var target = link.attr('href');
$.get('programs/programs.html',function(data){
$(target).html( data );
here.append(data);
});
});
Answer the question
In order to leave comments, you need to log in
Replace
$.get('programs/programs.html', function(data) {
$(target).html(data);
here.append(data);
});
$.get('programs/programs.html', function(data) {
here.append($(data).find(target));
});
From your code, you can see that when you click on the link, the ENTIRE programs/programs.html file will be loaded. There is no code that highlights its block.
Option 2
1. Parser - which, by regular expression, will select a block. For example, frame the code
<!-- CODE BLOCK NAME -->
<!-- /CODE BLOCK NAME -->
<%for (var i = 0; i < 10; i++) {%> <div>test</div> <%}%>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question