如果在页面上存在另一个div,我将如何隐藏div并仅显示它?我猜jquery或js将是要走的路......
<style type="text/css">
.always-here {
display:none;
}
</style>
<div class="im-here">This div exists on this particular page!</div>
<div class="always-here">This div is always here but has the style
display: none unless a div with the class "im-here" exists.</div>
Run Code Online (Sandbox Code Playgroud) 如果某些内容属实,如何用php插入一个类?到目前为止,这是我最好的猜测:
<div class="<?php
if($this->step==2){
somehow set the name of the class
} ?>">
Run Code Online (Sandbox Code Playgroud) 在 WooCommerce 的产品 > 属性 > [属性名称] > 添加新的 [属性变体] 下,有一个标题为“描述”的部分,文本为“默认情况下描述不突出;但是,某些主题可能会显示它。”
我想在我的主题中直接在附加信息选项卡中的属性变体下方显示它。这是我目前在那里的代码。我很感激有关如何让属性变体描述显示在属性变体下方的任何建议。
<td><?php
if ( $attribute['is_taxonomy'] ) {
$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
} else {
// Convert pipes to commas and display values
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
} …Run Code Online (Sandbox Code Playgroud) 我有一个单选按钮,如果选中="已选中",我想触发onclick事件.我是jQuery的新手,但我发现一些代码看起来应该可以做到这一点......除了我想我还不知道编辑它是否正确.任何建议,将不胜感激.
<input type="radio" checked="checked" id="id_of_Checkbox">
<input type="submit" id="id_of_button" onclick="doSomething" value="Submit">
<script type="text/javascript">
if ($('#id_of_Checkbox').prop('checked', true)){
(function(event){
$('#id_of_button').click();
});
}
</script>
Run Code Online (Sandbox Code Playgroud) jquery ×2
attributes ×1
class ×1
if-statement ×1
javascript ×1
php ×1
woocommerce ×1
wordpress ×1