Here is my code:
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$('.tree div').click(function(){
var id = $(this).attr('id');
$('.tree div:regex(id,^['+id+'_])').html('this one');
});
});
</script>
<div class="tree">
<div id="item_1">
<a href="<?php echo $this->url(array('action' => 'ketab')); ?>"><?php echo $this->translate("Add Ketab"); ?></a>
</div>
<div id="item_1_1">
<span></span>
<a href="<?php echo $this->url(array('action' => 'ketab')); ?>"><?php echo $this->translate("Add Ketab"); ?></a>
</div>
<div id="item_1_2">
<span></span>
<a href="<?php echo $this->url(array('action' => 'ketab')); ?>"><?php echo $this->translate("Add Ketab"); ?></a>
</div>
</div>
I want hide item_1_1 and item_1_2 when i click on item_1, I don’t know how can i do that with regex.
I use http://james.padolsey.com/javascript/regex-selector-for-jquery/ for regx
No need for the regex selector here. Use jQuery’s built-in attribute-starts-with selector:
If you just want to use that plugin anyway, then your selector would be: