jQuery를 사용하여 HTML을 생성하려고하는데 필요한 클래스 등으로 요소를 만든 다음 이해가된다면 서로에 추가하려고합니다. 아래 코드를 작성했지만 오류가 발생하지 않으며 HTML을 컨테이너에 추가하지도 않습니다.jQuery를 사용하여 HTML 생성
무엇이 잘못 되었나요?
(function($) {
$.fn.twitter_plugin = function(options) {
var container = this[0];
console.log('Started');
// Make aJax call
// Generate HTML
$con = $("<div>", { "class" : "tweet" });
$(container).append($con);
$col1 = $("<div>", { "class" : "twocol" });
$con.append($col1);
$col2 = $("<div>", { "class" : "tencol last" });
$con.append($col2);
// Profile Image
$tweet_profile_div = $("<div>", { "class" : "tweet-profile-photo" });
$col1.append($tweet_profile_div);
$profile_img = $("img", { "src" : '', "class" : "responsive-img" });
$tweet_profile_div.append($profile_img);
// END Profile Image
// Tweet
$tweet_head = $("div", { "class" : "tweet-head" });
// END Tweet
};
}(jQuery));
과 같이이 실행 :
<script src="js-src/themev2/twitter_plugin.js"></script>
<script>
$(document).ready(function() {
$("#map_canvas").twitter_plugin({ });
});
</script>
편집 한
을 console.log가 표시 될 때 @Sean 라이머, 내 twitter_plugin 기능은 당신이 제안이 변경없이 실행되고 , 이것은 문제가되지 않습니다.
콘솔 로그를 가져 왔습니까? – Adjit
jQuery를 포함 시켰습니까? – gaetanoM