@samara
To set a background-image using jQuery with CodeIgniter, you can do the following:
1
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
1 2 3 4 5 |
<script>
$(document).ready(function(){
$('#element_id').css('background-image', 'url(<?php echo base_url('path/to/your/image.jpg'); ?>)');
});
</script>
|
In this example, replace #element_id with the ID of the element you want to set the background image for, and path/to/your/image.jpg with the path to your image file within the CodeIgniter project.
1 2 3 4 |
public function index()
{
$this->load->view('your_view_file');
}
|
That's it! You have successfully set a background image using jQuery with CodeIgniter.