我似乎遇到了代码问题.我需要说:
if ( $('html').attr('lang').val() == 'fr-FR' ) {
// do this
} else {
// do that
}
Run Code Online (Sandbox Code Playgroud)
当我检查控制台时,我只是得到一个错误,告诉我这不是一个功能.帮助将不胜感激.
谢谢,
我一直在尝试使用 AJAX 提交嵌入式 Mailchimp 表单,但不使用 jQuery。显然,我没有正确地做这件事,因为我一直在结束“来吧,华生,来吧!游戏正在进行中。” 页 :(
任何帮助,这将是极大的赞赏。
在form action已经改变,以取代post?u=与post-json?u=和&c=?已添加到操作字符串的结尾。这是我的js:
document.addEventListener('DOMContentLoaded', function() {
function formMailchimp() {
var elForm = document.getElementById('mc-embedded-subscribe-form'),
elInputName = document.getElementById('mce-NAME'),
elInputEmail = document.getElementById('mce-EMAIL'),
strFormAction = elForm.getAttribute('action');
elForm.addEventListener('submit', function(e) {
var request = new XMLHttpRequest();
request.open('GET', strFormAction, true);
request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success!
var resp = JSON.parse(request.responseText);
request.send(resp);
} else {
console.log('We reached our …Run Code Online (Sandbox Code Playgroud) 我在网站上使用Packery.js [ http://packery.metafizzy.co/ ]并且在页面加载时遇到一些布局问题.我查看了Mason,Isotope和Packery的文档(所有非常相似的插件,全部由David DeSandro开发),并讨论了在加载所有图像以及任何webfonts之后应该触发布局的问题.
http://packery.metafizzy.co/appendix.html
我的Packery工作得很好,只能使用imagesLoaded ......但我不确定如何将Google Web Font加载器与之配合使用.下面是我加载字体的代码,后面是imagesLoaded Packery Layout.如果任何人都可以建议在Web字体和图像加载之后让Packery解雇,我将永远感激不尽.
// before <body>
<script type="text/javascript">
WebFontConfig = {
google: {
families: [ 'Bitter:400,700,400italic:latin' ]
},
typekit: {
id: // hidden for obvious reasons
}
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
// after </body>
// jquery and plugins are loaded prior to the …Run Code Online (Sandbox Code Playgroud) typekit jquery-masonry jquery-isotope webfont-loader packery
使用最新的jQuery(1.9.0),我很困惑为什么这段代码不起作用:
$.testAjaxFilter = function() {
var base = this;
// get faq categories
var currentFaqCategories = $('#category-list ul li a');
// loop through each faq category link and bind a click event to each
if ( typeof currentFaqCategories !== 'undefined') {
$.each(currentFaqCategories, function(index, category) {
$(category).click( function(e) {
$(e.target).getFaqList();
return false;
});
});
}
// GET faq list elements from category link
$.fn.getFaqList = function() {
$.get($(this[0]).attr('href'), function(data) {
base.addFaqSectionToPage( $(data).find('section.faq-page #content-column') );
});
};
// add new faq section …Run Code Online (Sandbox Code Playgroud) 我想知道为什么我的最后一个if语句永远不会执行.我想这样做:
$(document).ready(function() {
function checkWidth() {
var windowSize = $(window).width();
if (windowSize <= 479) {
console.log("screen width is less than 480");
}
else if (windowSize = 480 && windowSize <= 719) {
console.log("screen width is less than 720 but greater than or equal to 480");
}
else if (windowSize = 720 && windowSize <= 959) {
console.log("screen width is less than 960 but greater than or equal to 720");
}
else if (windowSize >= 960) {
console.log("screen width is greater …Run Code Online (Sandbox Code Playgroud) jquery ×3
ajax ×2
if-statement ×2
javascript ×2
attr ×1
conditional ×1
http-get ×1
mailchimp ×1
packery ×1
typekit ×1
width ×1
window ×1