# Building a simple jQuery plugin

**URL:** <https://forum.kirupa.com/t/building-a-simple-jquery-plugin/327993>\
**Category:** Uncategorized\
**Created:** [April 11, 2012, 1:13pm UTC](https://forum.kirupa.com/t/building-a-simple-jquery-plugin/327993 "2012-04-11T13:13:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeancnicolas](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jeancnicolas](https://forum.kirupa.com/u/jeancnicolas)\
**Post date:** [April 11, 2012, 1:13pm UTC](https://forum.kirupa.com/t/building-a-simple-jquery-plugin/327993/1 "2012-04-11T13:13:22Z")

</div>

hello …  
I basically have a load of code using jQuery, that I now realise I have to add an if statement to every on(‘mouseenter’) event I have depending on whether or not a boolean is true or false.  
Ok - easy. But I wish to build a jQuery plugin (at the most simplest level), so that my query will continue and chain - or break. Is there a jQuery method that already exists that does that?

Otherwise::

```auto
var myBreak = true;
jQuery.fn.makeOrBreak = function(v){    
// break chain or query
if(v != true){
}else{
// keep calm and carry on
}
};
// usage example
$('#id').makeOrBreak(myBreak).hide(); // boolean is true so '#id' is allowed to chain and 'hide()'

```

maybe there’s easier ways - but it’s interesting to build a plugin. And I have around 40 mouse overs ive got to plug an if statement into …  
Any pointers!?

PS am i in the right forum?!
