我正在写一个声明,说如果#process-description中有任何内容显示#process-work,则隐藏它。
HTML
<div id="process-work">
<h2 id="process-title">Process Work</h2>
<p id="process-description"></p>
</div>
JS
'zeckoshop' : {
'title' : 'zeckoShop',
'description' : 'An all-in-one ecommerce platform designed to seamlessly integrate with your business operations.',
'link' : 'http://darrenbachan.com/playground/zeckoshop/index.html',
'images': [
'/images/zeckoshop/zeckoshop-1.jpg'
],
'tags': [
'Web Design',
'Web Development'
],
'process-description' : 'An all-in-one ecommerce platform designed to seamlessly integrate with your business operations.',
'process-wireframes': [
'/images/zeckoshop/zeckoshop-1.jpg'
]
}
if('#process-work') {
$('#process-description').html(projectData['process-description']).show();
} else {
$('#process-work').hide();
}
答案 0 :(得分:1)
我认为您正在寻找代码中的这一变化:
if($('#process-description').length) {
$('#process-description').html(projectData['process-description']).show();
} else {
$('#process-work').hide();
}